add new apis
This commit is contained in:
22
core/apps/shared/paginations/custom.py
Normal file
22
core/apps/shared/paginations/custom.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from rest_framework.pagination import PageNumberPagination
|
||||
|
||||
|
||||
from rest_framework.pagination import PageNumberPagination
|
||||
from rest_framework.response import Response
|
||||
|
||||
class CustomPageNumberPagination(PageNumberPagination):
|
||||
page_size = 10
|
||||
page_query_param = 'page'
|
||||
page_size_query_param = 'page_size'
|
||||
max_page_size = 100
|
||||
|
||||
def get_paginated_response(self, data):
|
||||
return Response({
|
||||
'total': self.page.paginator.count,
|
||||
'page': self.page.number,
|
||||
'page_size': self.get_page_size(self.request),
|
||||
'total_pages': self.page.paginator.num_pages,
|
||||
'has_next': self.page.has_next(),
|
||||
'has_previous': self.page.has_previous(),
|
||||
'results': data
|
||||
})
|
||||
Reference in New Issue
Block a user