Files
crmApi/utils/pagination/custom_pagination_style_1.py
T
2024-01-22 13:01:42 +03:30

16 lines
643 B
Python

from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
class CustomPagination(PageNumberPagination):
def get_paginated_response(self, data):
return Response({
'links': {
'next': self.get_next_link(),
'next_page': self.page.next_page_number() if self.page.has_next() else None,
'previous': self.get_previous_link(),
'previous_page': self.page.previous_page_number() if self.page.has_previous() else None
},
'count': self.page.paginator.count,
'results': data
})