File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -6,14 +6,16 @@ def pagination_system_check(app_configs, **kwargs):
66 errors = []
77 # Use of default page size setting requires a default Paginator class
88 from rest_framework .settings import api_settings
9- if api_settings .PAGE_SIZE and not api_settings .DEFAULT_PAGINATION_CLASS :
9+ if (
10+ api_settings .PAGE_SIZE or api_settings .MAX_PAGE_SIZE
11+ ) and not api_settings .DEFAULT_PAGINATION_CLASS :
1012 errors .append (
1113 Warning (
12- "You have specified a default PAGE_SIZE pagination rest_framework setting, "
14+ "You have specified a default PAGE_SIZE pagination or MAX_PAGE_SIZE limit rest_framework setting, "
1315 "without specifying also a DEFAULT_PAGINATION_CLASS." ,
1416 hint = "The default for DEFAULT_PAGINATION_CLASS is None. "
1517 "In previous versions this was PageNumberPagination. "
16- "If you wish to define PAGE_SIZE globally whilst defining "
18+ "If you wish to define PAGE_SIZE or MAX_PAGE_SIZE globally whilst defining "
1719 "pagination_class on a per-view basis you may silence this check." ,
1820 id = "rest_framework.W001"
1921 )
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ def get_pagination_error(error_id: str):
5454 return next ((error for error in errors if error .id == error_id ), None )
5555
5656 self .assertIsNone (api_settings .PAGE_SIZE )
57+ self .assertIsNone (api_settings .MAX_PAGE_SIZE )
5758 self .assertIsNone (api_settings .DEFAULT_PAGINATION_CLASS )
5859
5960 pagination_error = get_pagination_error ('rest_framework.W001' )
@@ -63,11 +64,19 @@ def get_pagination_error(error_id: str):
6364 pagination_error = get_pagination_error ('rest_framework.W001' )
6465 self .assertIsNotNone (pagination_error )
6566
67+ with override_settings (REST_FRAMEWORK = {'MAX_PAGE_SIZE' : 10 }):
68+ pagination_error = get_pagination_error ('rest_framework.W001' )
69+ self .assertIsNotNone (pagination_error )
70+
6671 default_pagination_class = 'rest_framework.pagination.PageNumberPagination'
6772 with override_settings (REST_FRAMEWORK = {'PAGE_SIZE' : 10 , 'DEFAULT_PAGINATION_CLASS' : default_pagination_class }):
6873 pagination_error = get_pagination_error ('rest_framework.W001' )
6974 self .assertIsNone (pagination_error )
7075
76+ with override_settings (REST_FRAMEWORK = {'MAX_PAGE_SIZE' : 10 , 'DEFAULT_PAGINATION_CLASS' : default_pagination_class }):
77+ pagination_error = get_pagination_error ('rest_framework.W001' )
78+ self .assertIsNone (pagination_error )
79+
7180
7281class TestSettingTypes (TestCase ):
7382 def test_settings_consistently_coerced_to_list (self ):
You can’t perform that action at this time.
0 commit comments