From 6f6d402d043acb6400736f882c6a48e3c7e773f4 Mon Sep 17 00:00:00 2001 From: sarath ak Date: Wed, 10 Mar 2021 18:02:10 +0530 Subject: [PATCH] Allow 'get_page' method for overriding #7626 (#7652) --- rest_framework/pagination.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rest_framework/pagination.py b/rest_framework/pagination.py index 4db646116..0f0aa9ccf 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 = request.query_params.get(self.page_query_param, 1) + page_number = self.get_page_number(request) if page_number in self.last_page_strings: page_number = paginator.num_pages @@ -217,6 +217,9 @@ class PageNumberPagination(BasePagination): self.request = request 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): return Response(OrderedDict([ ('count', self.page.paginator.count),