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()}
评论列表
文章目录