| 1 |
from django.core.checks import Tags, Warning, register |
| 2 |
|
| 3 |
|
| 4 |
@register(Tags.compatibility) |
| 5 |
def pagination_system_check(app_configs, **kwargs): |
| 6 |
errors = [] |
| 7 |
# Use of default page size setting requires a default Paginator class |
| 8 |
from rest_framework.settings import api_settings |
| 9 |
if api_settings.PAGE_SIZE and not api_settings.DEFAULT_PAGINATION_CLASS: |
| 10 |
errors.append( |
| 11 |
Warning( |
| 12 |
"You have specified a default PAGE_SIZE pagination rest_framework setting, " |
| 13 |
"without specifying also a DEFAULT_PAGINATION_CLASS.", |
| 14 |
hint="The default for DEFAULT_PAGINATION_CLASS is None. " |
| 15 |
"In previous versions this was PageNumberPagination. " |
| 16 |
"If you wish to define PAGE_SIZE globally whilst defining " |
| 17 |
"pagination_class on a per-view basis you may silence this check.", |
| 18 |
id="rest_framework.W001" |
| 19 |
) |
| 20 |
) |
| 21 |
return errors |