Fix 'get_page_number' implementation

This commit is contained in:
Tom Christie 2021-03-11 09:21:22 +00:00
parent c05cbe2da2
commit 39a98c80a6

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 = self.get_page_number(request) page_number = self.get_page_number(request, paginator)
try: try:
self.page = paginator.page(page_number) self.page = paginator.page(page_number)
@ -215,7 +215,7 @@ class PageNumberPagination(BasePagination):
self.request = request self.request = request
return list(self.page) return list(self.page)
def get_page_number(self, request): def get_page_number(self, request, paginator):
page_number = request.query_params.get(self.page_query_param, 1) page_number = request.query_params.get(self.page_query_param, 1)
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