I used custom pagination as mentioned in Django rest framework. In that, I had to use my project name to give the path to CustomPagination, but every time it says module not found.
Then I manually import the pagination file in my views. It did work but my pagination links are appearing null. I have posted the picture here below.
My views:
from .pagination import CustomPagination
class ProductAPIView(ListAPIView):
permission_classes = [AllowAny]
queryset = Product.objects.all()
serializer_class = ProductSerializer
filterset_class = ProductFilter
pagination_class = CustomPagination
My pagination.py file
class CustomPagination(PageNumberPagination):
def get_paginated_response(self, data):
return Response({
'links': {
'next': self.get_next_link(),
'previous': self.get_previous_link()
},
'count': self.page.paginator.count,
'results': data
})
My settings file:
# 'DEFAULT_PAGINATION_CLASS': 'RupseOnline.core.pagination.CustomPagination',
'PAGE_SIZE': 100,
I have commented out the pagination class and imported it manually in views because it says module not found.