[Answered ]-LimitOffsetPagination with viewsets.ViewSet in Django Rest Framework

1👍

You can use django-rest default pagination style for entire app using below code in settings.py

REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
'PAGE_SIZE': 50 }

If you need pagination per view you can make it as per documentation

class StandardResultsSetPagination(PageNumberPagination):
    page_size = 100
    page_size_query_param = 'page_size'
    max_page_size = 1000

Then Use it in your View

class viewclass(APIView):
queryset = customquery
serializer_class = serializerclass
pagination_class = LargeResultsSetPagination

Using Parameters can also help like
GET https://api.example.org/accounts/?limit=100&offset=400

Leave a comment