Fixed #29703 -- Deprecated QuerySetPaginator alias.
Unused since 4406d283e1
.
This commit is contained in:
parent
44f98f7880
commit
ed4bfacb3c
|
@ -3,6 +3,7 @@ import inspect
|
||||||
import warnings
|
import warnings
|
||||||
from math import ceil
|
from math import ceil
|
||||||
|
|
||||||
|
from django.utils.deprecation import RemovedInDjango31Warning
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
from django.utils.inspect import method_has_no_args
|
from django.utils.inspect import method_has_no_args
|
||||||
from django.utils.translation import gettext_lazy as _
|
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):
|
class Page(collections.abc.Sequence):
|
||||||
|
|
|
@ -17,6 +17,8 @@ details on these changes.
|
||||||
|
|
||||||
* ``django.utils.timezone.FixedOffset`` will be removed.
|
* ``django.utils.timezone.FixedOffset`` will be removed.
|
||||||
|
|
||||||
|
* ``django.core.paginator.QuerySetPaginator`` will be removed.
|
||||||
|
|
||||||
.. _deprecation-removed-in-3.0:
|
.. _deprecation-removed-in-3.0:
|
||||||
|
|
||||||
3.0
|
3.0
|
||||||
|
|
|
@ -293,3 +293,6 @@ Miscellaneous
|
||||||
|
|
||||||
* ``django.utils.timezone.FixedOffset`` is deprecated in favor of
|
* ``django.utils.timezone.FixedOffset`` is deprecated in favor of
|
||||||
:class:`datetime.timezone`.
|
:class:`datetime.timezone`.
|
||||||
|
|
||||||
|
* The undocumented ``QuerySetPaginator`` alias of
|
||||||
|
``django.core.paginator.Paginator`` is deprecated.
|
||||||
|
|
|
@ -2,10 +2,11 @@ import warnings
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from django.core.paginator import (
|
from django.core.paginator import (
|
||||||
EmptyPage, InvalidPage, PageNotAnInteger, Paginator,
|
EmptyPage, InvalidPage, PageNotAnInteger, Paginator, QuerySetPaginator,
|
||||||
UnorderedObjectListWarning,
|
UnorderedObjectListWarning,
|
||||||
)
|
)
|
||||||
from django.test import SimpleTestCase, TestCase
|
from django.test import SimpleTestCase, TestCase
|
||||||
|
from django.utils.deprecation import RemovedInDjango31Warning
|
||||||
|
|
||||||
from .custom import ValidAdjacentNumsPaginator
|
from .custom import ValidAdjacentNumsPaginator
|
||||||
from .models import Article
|
from .models import Article
|
||||||
|
@ -297,6 +298,12 @@ class PaginationTests(SimpleTestCase):
|
||||||
with self.assertRaises(EmptyPage):
|
with self.assertRaises(EmptyPage):
|
||||||
paginator.get_page(1)
|
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):
|
class ModelPaginationTests(TestCase):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue