diff --git a/rest_framework/__init__.py b/rest_framework/__init__.py index c0b5c4c04..967f87019 100644 --- a/rest_framework/__init__.py +++ b/rest_framework/__init__.py @@ -6,6 +6,7 @@ ______ _____ _____ _____ __ | |\ \| |___/\__/ / | | | | | | | (_| | | | | | | __/\ V V / (_) | | | < \_| \_\____/\____/ \_/ |_| |_| \__,_|_| |_| |_|\___| \_/\_/ \___/|_| |_|\_| """ +import checks # NOQA __title__ = 'Django REST framework' __version__ = '3.6.3' diff --git a/rest_framework/checks.py b/rest_framework/checks.py new file mode 100644 index 000000000..96d6f4237 --- /dev/null +++ b/rest_framework/checks.py @@ -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 diff --git a/rest_framework/pagination.py b/rest_framework/pagination.py index 0b6155942..0255cfc7f 100644 --- a/rest_framework/pagination.py +++ b/rest_framework/pagination.py @@ -5,7 +5,6 @@ be used for paginated responses. """ from __future__ import unicode_literals -import warnings from base64 import b64decode, b64encode 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): 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 raise NotImplementedError('paginate_queryset() must be implemented.')