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):
6
6
errors = []
7
7
# Use of default page size setting requires a default Paginator class
8
8
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 :
10
12
errors .append (
11
13
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, "
13
15
"without specifying also a DEFAULT_PAGINATION_CLASS." ,
14
16
hint = "The default for DEFAULT_PAGINATION_CLASS is None. "
15
17
"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 "
17
19
"pagination_class on a per-view basis you may silence this check." ,
18
20
id = "rest_framework.W001"
19
21
)
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ def get_pagination_error(error_id: str):
54
54
return next ((error for error in errors if error .id == error_id ), None )
55
55
56
56
self .assertIsNone (api_settings .PAGE_SIZE )
57
+ self .assertIsNone (api_settings .MAX_PAGE_SIZE )
57
58
self .assertIsNone (api_settings .DEFAULT_PAGINATION_CLASS )
58
59
59
60
pagination_error = get_pagination_error ('rest_framework.W001' )
@@ -63,11 +64,19 @@ def get_pagination_error(error_id: str):
63
64
pagination_error = get_pagination_error ('rest_framework.W001' )
64
65
self .assertIsNotNone (pagination_error )
65
66
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
+
66
71
default_pagination_class = 'rest_framework.pagination.PageNumberPagination'
67
72
with override_settings (REST_FRAMEWORK = {'PAGE_SIZE' : 10 , 'DEFAULT_PAGINATION_CLASS' : default_pagination_class }):
68
73
pagination_error = get_pagination_error ('rest_framework.W001' )
69
74
self .assertIsNone (pagination_error )
70
75
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
+
71
80
72
81
class TestSettingTypes (TestCase ):
73
82
def test_settings_consistently_coerced_to_list (self ):
You can’t perform that action at this time.
0 commit comments