Generateurv2/backend/api/exercices/paginations.py
2022-06-24 13:42:16 +02:00

23 lines
679 B
Python

from rest_framework import pagination
from rest_framework.response import Response
class CustomPagination(pagination.PageNumberPagination):
page_size_query_param='s'
page_query_param='p'
page_size=20
def get_paginated_response(self, data):
return Response({
'links': {
'next': self.get_next_link(),
'previous': self.get_previous_link(),
},
'count': self.page.paginator.count,
'page_size': self.page.paginator.per_page,
'pages': self.page.paginator.num_pages,
'page_number': self.page.number,
'results': data
})