Allow 'get_page' method for overriding #7626 (#7652)

This commit is contained in:
sarath ak 2021-03-10 18:02:10 +05:30 committed by GitHub
parent c603b98403
commit 6f6d402d04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -198,7 +198,7 @@ class PageNumberPagination(BasePagination):
return None return None
paginator = self.django_paginator_class(queryset, page_size) paginator = self.django_paginator_class(queryset, page_size)
page_number = request.query_params.get(self.page_query_param, 1) page_number = self.get_page_number(request)
if page_number in self.last_page_strings: if page_number in self.last_page_strings:
page_number = paginator.num_pages page_number = paginator.num_pages
@ -217,6 +217,9 @@ class PageNumberPagination(BasePagination):
self.request = request self.request = request
return list(self.page) return list(self.page)
def get_page_number(self, request):
return request.query_params.get(self.page_query_param, 1)
def get_paginated_response(self, data): def get_paginated_response(self, data):
return Response(OrderedDict([ return Response(OrderedDict([
('count', self.page.paginator.count), ('count', self.page.paginator.count),