from rest_framework.pagination import PageNumberPagination, CursorPagination
class BasePagination(PageNumberPagination):
page_size = 3
page_size_query_param = "page_size"
class PageViewSet(...):
...
...
...
pagination_class = BasePagination
...
def list(self, request):
page = self.paginate_queryset(self.get_queryset())
if page is not None:
serializer = self.get_serializer(page, many=True)
return self.get_paginated_response(serializer.data)