base.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:falcon-api 作者: Opentopic 项目源码 文件源码
def get_total_objects(self, queryset, totals):
        """
        Return total number of results in a query.

        :param queryset: queryset object from :func:`get_queryset`

        :param totals: a list of dicts with aggregate function as key and column as value
        :type totals: list

        :return: dict with totals calculated in this query, ex. total_count with number of results
        :rtype: dict
        """
        if not totals:
            return {}
        for total in totals:
            if len(total) > 1 or 'count' not in total or total['count'] is not None:
                raise falcon.HTTPBadRequest('Invalid attribute', 'Only _count_ is supported in the _totals_ param')
        return {'total_count': queryset.count()}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号