Add LimitOffsetPagination.get_count to allow method override by chukkwagon · Pull Request #5846 · encode/django-rest-framework (original) (raw)

Description

This PR:

I have a custom pagination class that subclasses LimitOffsetPagination. When paginating a large queryset with an .order_by() clause, the combination of sorting can add a lot of overhead to the pagination calculation, which in turn slows down the entire response. Adding get_count() as an instance method gives developers the ability to override it's behavior if necessary. In my case, I will override the method to remove any ordering constraints from the queryset.