From 39a98c80a6cb0b21fb6adb5ee97bc64b8b404433 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 11 Mar 2021 09:21:22 +0000 Subject: [PATCH] Fix 'get_page_number' implementation --- rest_framework/pagination.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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