diff --git a/rest_framework/pagination.py b/rest_framework/pagination.py index 87ff7d3d6..91da73de6 100644 --- a/rest_framework/pagination.py +++ b/rest_framework/pagination.py @@ -198,7 +198,7 @@ class PageNumberPagination(BasePagination): return None paginator = self.django_paginator_class(queryset, page_size) - page_number = self.get_page_number(request) + page_number = self.get_page_number(request, paginator) try: self.page = paginator.page(page_number) @@ -215,7 +215,7 @@ class PageNumberPagination(BasePagination): self.request = request 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) if page_number in self.last_page_strings: page_number = paginator.num_pages