2022-06-11 23:39:03 +02:00
|
|
|
|
|
|
|
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(),
|
2022-06-24 13:42:16 +02:00
|
|
|
'previous': self.get_previous_link(),
|
|
|
|
|
2022-06-11 23:39:03 +02:00
|
|
|
},
|
|
|
|
'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
|
|
|
|
})
|