Turn off automatic pagination of Django Rest Framework ModelViewSet

Bill Noble picture Bill Noble · Apr 11, 2016 · Viewed 12.3k times · Source

I am using Django Rest Framework's ModelViewSet for one of my views. ModelViewSet uses the ListModelMixin which automatically paginates the results but I do not want the results paginated. In my API call I say how many results I want returned but as it stands I can't get back more than 10 results in one call.

Is there a way to turn off the automatic pagination and so I can have as many results as I want returned?

Answer

trinchet picture trinchet · Apr 11, 2016

If you are using recent versions of DRF you just need to add pagination_class = None to your ModelViewSet definition.

class MyClassBasedView(ModelViewSet):
    pagination_class = None
    ...

You also can see some tips here https://github.com/tomchristie/django-rest-framework/issues/1390