From eea623e0d2d5345cb20bafc7cf5e87a6d157370e Mon Sep 17 00:00:00 2001 From: Taranjeet Singh Date: Wed, 21 Apr 2021 20:54:13 +0530 Subject: [PATCH] Fix #7575 Take max_limit into account when no limit parameter is present in the request with LimitOffsetPagination class. If max_limit is less than default limit then max_limit will be returned. --- rest_framework/pagination.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rest_framework/pagination.py b/rest_framework/pagination.py index dc120d8e8..92b54db8c 100644 --- a/rest_framework/pagination.py +++ b/rest_framework/pagination.py @@ -439,7 +439,13 @@ class LimitOffsetPagination(BasePagination): except (KeyError, ValueError): pass - return self.default_limit + return self.get_lower_of_max_or_default_limit() + + def get_lower_of_max_or_default_limit(self): + try: + return min(self.max_limit, self.default_limit) + except TypeError: + return self.default_limit def get_offset(self, request): try: