diff options
| author | Nick Pope <nick.pope@flightdataservices.com> | 2018-08-22 19:40:14 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-08-27 16:23:43 -0400 |
| commit | ed4bfacb3c942d0d32795e1a733b1b9367afd2e9 (patch) | |
| tree | 9a75d8337cc33a2e2bb4b6b325e8287d77ecbd82 | |
| parent | 44f98f78804627839d5f0a8b3a32bfbb4546ff52 (diff) | |
Fixed #29703 -- Deprecated QuerySetPaginator alias.
Unused since 4406d283e13819b04556df21044089b7d119edb0.
| -rw-r--r-- | django/core/paginator.py | 10 | ||||
| -rw-r--r-- | docs/internals/deprecation.txt | 2 | ||||
| -rw-r--r-- | docs/releases/2.2.txt | 3 | ||||
| -rw-r--r-- | tests/pagination/tests.py | 9 |
4 files changed, 22 insertions, 2 deletions
diff --git a/django/core/paginator.py b/django/core/paginator.py index d48a244a44..d484c31ed5 100644 --- a/django/core/paginator.py +++ b/django/core/paginator.py @@ -3,6 +3,7 @@ import inspect import warnings from math import ceil +from django.utils.deprecation import RemovedInDjango31Warning from django.utils.functional import cached_property from django.utils.inspect import method_has_no_args from django.utils.translation import gettext_lazy as _ @@ -125,7 +126,14 @@ class Paginator: ) -QuerySetPaginator = Paginator # For backwards-compatibility. +class QuerySetPaginator(Paginator): + + def __init__(self, *args, **kwargs): + warnings.warn( + 'The QuerySetPaginator alias of Paginator is deprecated.', + RemovedInDjango31Warning, stacklevel=2, + ) + super().__init__(*args, **kwargs) class Page(collections.abc.Sequence): diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt index 6d8ff36835..d7b02fa3bc 100644 --- a/docs/internals/deprecation.txt +++ b/docs/internals/deprecation.txt @@ -17,6 +17,8 @@ details on these changes. * ``django.utils.timezone.FixedOffset`` will be removed. +* ``django.core.paginator.QuerySetPaginator`` will be removed. + .. _deprecation-removed-in-3.0: 3.0 diff --git a/docs/releases/2.2.txt b/docs/releases/2.2.txt index ff692151ed..5881265cbf 100644 --- a/docs/releases/2.2.txt +++ b/docs/releases/2.2.txt @@ -293,3 +293,6 @@ Miscellaneous * ``django.utils.timezone.FixedOffset`` is deprecated in favor of :class:`datetime.timezone`. + +* The undocumented ``QuerySetPaginator`` alias of + ``django.core.paginator.Paginator`` is deprecated. diff --git a/tests/pagination/tests.py b/tests/pagination/tests.py index 8ab04940ab..20e74981cd 100644 --- a/tests/pagination/tests.py +++ b/tests/pagination/tests.py @@ -2,10 +2,11 @@ import warnings from datetime import datetime from django.core.paginator import ( - EmptyPage, InvalidPage, PageNotAnInteger, Paginator, + EmptyPage, InvalidPage, PageNotAnInteger, Paginator, QuerySetPaginator, UnorderedObjectListWarning, ) from django.test import SimpleTestCase, TestCase +from django.utils.deprecation import RemovedInDjango31Warning from .custom import ValidAdjacentNumsPaginator from .models import Article @@ -297,6 +298,12 @@ class PaginationTests(SimpleTestCase): with self.assertRaises(EmptyPage): paginator.get_page(1) + def test_querysetpaginator_deprecation(self): + msg = 'The QuerySetPaginator alias of Paginator is deprecated.' + with self.assertWarnsMessage(RemovedInDjango31Warning, msg) as cm: + QuerySetPaginator([], 1) + self.assertEqual(cm.filename, __file__) + class ModelPaginationTests(TestCase): """ |
