I am trying to use PageNumberPagination
in DRF anf for that I have changed the settings.py file like the following:
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_simplejwt.authentication.JWTAuthentication',
),
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
# 'PAGE_SIZE':10
}
and views.py
from rest_framework.pagination import PageNumberPagination
class GrnListAPIView(generics.ListAPIView):
serializer_class = GrnListSerializer
pagination_class = PageNumberPagination
permission_classes = (permissions.IsAuthenticated, GRNViewPermission)
def get_queryset(self):
return Grn.objects.all()
now when I try to access the data using the URL:
http://localhost:8000/grns/?page=1&page_size=10
It gives me all the data rather than returning 10 objects. It works fine when I uncomment the PAGE_SIZE
but only returns 10 values per page, which is understandable as I have mentioned
page_size=10
in my params but when I change it to 20 or 30 it still returns the same amount of data instead of 20 or 30 objects.