diff options
| author | wookkl <wjddnr315@gmail.com> | 2025-03-19 01:30:48 +0900 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-03-25 12:04:13 +0100 |
| commit | 334677ad576400a3b74da3f89ac70314235c1876 (patch) | |
| tree | 03c2b7770853df5ac8cb2deea215076f8e698f81 /django | |
| parent | fecca298a2c6de22b054eaffeb4368b1167c7fd5 (diff) | |
Fixed #35452 -- Deprecated orphans being more than or equal to page_size in pagination.
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/paginator.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/django/core/paginator.py b/django/core/paginator.py index 422da30aa1..2bf858cd54 100644 --- a/django/core/paginator.py +++ b/django/core/paginator.py @@ -6,6 +6,7 @@ from math import ceil from asgiref.sync import sync_to_async +from django.utils.deprecation import RemovedInDjango70Warning from django.utils.functional import cached_property from django.utils.inspect import method_has_no_args from django.utils.translation import gettext_lazy as _ @@ -55,6 +56,18 @@ class BasePaginator: if error_messages is None else self.default_error_messages | error_messages ) + if self.per_page <= self.orphans: + # RemovedInDjango70Warning: When the deprecation ends, replace with: + # raise ValueError( + # "The orphans argument cannot be larger than or equal to the " + # "per_page argument." + # ) + msg = ( + "Support for the orphans argument being larger than or equal to the " + "per_page argument is deprecated. This will raise a ValueError in " + "Django 7.0." + ) + warnings.warn(msg, category=RemovedInDjango70Warning, stacklevel=2) def _check_object_list_is_ordered(self): """ |
