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?
If you are using recent versions of DRF you just need to add pagination_class = None to your ModelViewSet definition.
Pagination is only performed automatically if you're using the generic views or viewsets. If you're using a regular APIView , you'll need to call into the pagination API yourself to ensure you return a paginated response. See the source code for the mixins. ListModelMixin and generics.
Django REST framework (DRF) is a powerful and flexible toolkit for building Web APIs. Its main benefit is that it makes serialization much easier. Django REST framework is based on Django's class-based views, so it's an excellent option if you're familiar with Django.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With