Commit dbef3767 by Peter Fogg

Merge pull request #8999 from edx/peter-fogg/tnl-2703

Remove unnecessary DB call in team pagination.
parents 69a1a069 948f652c
......@@ -319,7 +319,14 @@ class TeamsListView(ExpandableFieldViewMixin, GenericAPIView):
queryset = queryset.order_by(order_by_field)
page = self.paginate_queryset(queryset)
# TODO: Remove this on update to Django 1.8
# Use the cached length of the queryset in order to avoid
# making an extra database call to get the number of items in
# the collection
paginator = self.paginator_class(queryset, self.get_paginate_by())
paginator._count = len(queryset) # pylint: disable=protected-access
page = paginator.page(int(request.QUERY_PARAMS.get('page', 1)))
# end TODO
serializer = self.get_pagination_serializer(page)
serializer.context.update({'sort_order': order_by_input}) # pylint: disable=maybe-no-member
return Response(serializer.data) # pylint: disable=maybe-no-member
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment