tomchristie/django-rest-framework — pull request #579 by svartalf (2013-01-14 03:44:18+00:00)
Title: Pass real queryset object to MultipleObjectMixin.paginate_queryset

If filtering is enabled, instead of a QuerySet object, [AutoFilterSet object is passed](https://github.com/tomchristie/django-rest-framework/blob/cae9a334ce1cb88b85d9619e473f7d4c550b68d5/rest_framework/filters.py#L56) to the [django.views.generic.list.MultipleObjectMixin.paginate_queryset](https://github.com/django/django/blob/4720117a31344483119856fb5ed803fe4c35936f/django/views/generic/list.py#L43) method. So, when the paginator tries to count amount of the objects, it fails to call the method `count()` of the `queryset` object and [fallbacks](https://github.com/django/django/blob/4720117a31344483119856fb5ed803fe4c35936f/django/db/models/query.py#L81) to the `len(list(queryset))`.

It can be really slow, so I suggest to pass a filtered queryset from the AutoFilterSet object to the paginator.