Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a system checks file
Add a check for pagination settings for the 3.7 upgrade cycle.
  • Loading branch information
matteius committed Sep 25, 2017
commit 420bc48cfdb5336656cd54d5557703e39618c92e
1 change: 1 addition & 0 deletions rest_framework/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
| |\ \| |___/\__/ / | | | | | | | (_| | | | | | | __/\ V V / (_) | | | <
\_| \_\____/\____/ \_/ |_| |_| \__,_|_| |_| |_|\___| \_/\_/ \___/|_| |_|\_|
"""
import checks # NOQA

__title__ = 'Django REST framework'
__version__ = '3.6.3'
Expand Down
20 changes: 20 additions & 0 deletions rest_framework/checks.py
Original file line number Diff line number Diff line change
@@ -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. "
Copy link
Collaborator

@carltongibson carltongibson Sep 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The default for DEFAULT_PAGINATION_CLASS is None. (In previous versions this was PageNumberPagination)"

"Consider specifying `DEFAULT_PAGINATION_CLASS` explicitly for your project, "
"unless you specify individual pagination_class values on specific view classes.",
)
)
return errors
12 changes: 0 additions & 12 deletions rest_framework/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""
from __future__ import unicode_literals

import warnings
from base64 import b64decode, b64encode
from collections import OrderedDict, namedtuple

Expand Down Expand Up @@ -147,17 +146,6 @@ def invert(x):
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.')

Expand Down