mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 12:30:11 +03:00
Add a system checks file
Add a check for pagination settings for the 3.7 upgrade cycle.
This commit is contained in:
parent
a224b6b935
commit
420bc48cfd
|
@ -6,6 +6,7 @@ ______ _____ _____ _____ __
|
||||||
| |\ \| |___/\__/ / | | | | | | | (_| | | | | | | __/\ V V / (_) | | | <
|
| |\ \| |___/\__/ / | | | | | | | (_| | | | | | | __/\ V V / (_) | | | <
|
||||||
\_| \_\____/\____/ \_/ |_| |_| \__,_|_| |_| |_|\___| \_/\_/ \___/|_| |_|\_|
|
\_| \_\____/\____/ \_/ |_| |_| \__,_|_| |_| |_|\___| \_/\_/ \___/|_| |_|\_|
|
||||||
"""
|
"""
|
||||||
|
import checks # NOQA
|
||||||
|
|
||||||
__title__ = 'Django REST framework'
|
__title__ = 'Django REST framework'
|
||||||
__version__ = '3.6.3'
|
__version__ = '3.6.3'
|
||||||
|
|
20
rest_framework/checks.py
Normal file
20
rest_framework/checks.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
from django.core.checks import Tags, Warning, register
|
||||||
|
|
||||||
|
|
||||||
|
@register(Tags.compatibility)
|
||||||
|
def pagination_system_check(app_configs, **kwargs):
|
||||||
|
errors = []
|
||||||
|
# Use of default page size setting requires a default Paginator class
|
||||||
|
from rest_framework.settings import api_settings
|
||||||
|
if api_settings.PAGE_SIZE and not api_settings.DEFAULT_PAGINATION_CLASS:
|
||||||
|
errors.append(
|
||||||
|
Warning(
|
||||||
|
"You have specified a default PAGE_SIZE` pagination rest_framework setting,"
|
||||||
|
"without specifying also a `DEFAULT_PAGINATION_CLASS`.",
|
||||||
|
hint="The prior version of rest_framework defaulted this setting to "
|
||||||
|
"`PageNumberPagination` however pagination defaults to disabled now. "
|
||||||
|
"Consider specifying `DEFAULT_PAGINATION_CLASS` explicitly for your project, "
|
||||||
|
"unless you specify individual pagination_class values on specific view classes.",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return errors
|
|
@ -5,7 +5,6 @@ be used for paginated responses.
|
||||||
"""
|
"""
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import warnings
|
|
||||||
from base64 import b64decode, b64encode
|
from base64 import b64decode, b64encode
|
||||||
from collections import OrderedDict, namedtuple
|
from collections import OrderedDict, namedtuple
|
||||||
|
|
||||||
|
@ -147,17 +146,6 @@ PAGE_BREAK = PageLink(url=None, number=None, is_active=False, is_break=True)
|
||||||
class BasePagination(object):
|
class BasePagination(object):
|
||||||
display_page_controls = False
|
display_page_controls = False
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
# Use of default page size setting requires a default Paginator class
|
|
||||||
if api_settings.PAGE_SIZE and not api_settings.DEFAULT_PAGINATION_CLASS:
|
|
||||||
warnings.warn(
|
|
||||||
"A valid paginator class must be specified with `DEFAULT_PAGINATION_CLASS` "
|
|
||||||
"when using the `PAGE_SIZE` default pagination setting."
|
|
||||||
"Defaulting the setting to specifies `PageNumberPagination` "
|
|
||||||
"is deprecated as pagination is disabled by default.",
|
|
||||||
DeprecationWarning
|
|
||||||
)
|
|
||||||
|
|
||||||
def paginate_queryset(self, queryset, request, view=None): # pragma: no cover
|
def paginate_queryset(self, queryset, request, view=None): # pragma: no cover
|
||||||
raise NotImplementedError('paginate_queryset() must be implemented.')
|
raise NotImplementedError('paginate_queryset() must be implemented.')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user