Skip to content
Snippets Groups Projects
Commit 948f652c authored by Peter Fogg's avatar Peter Fogg
Browse files

Remove unnecessary DB call in team pagination.

parent c0eaeb7e
Branches
Tags
No related merge requests found
......@@ -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
......
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