mirror of
https://github.com/django/django.git
synced 2025-10-27 07:36:08 +00:00
Fixed #28284 -- Prevented Paginator's unordered object list warning from evaluating a QuerySet.
This commit is contained in:
@@ -96,10 +96,16 @@ class Paginator:
|
||||
"""
|
||||
Warn if self.object_list is unordered (typically a QuerySet).
|
||||
"""
|
||||
if hasattr(self.object_list, 'ordered') and not self.object_list.ordered:
|
||||
ordered = getattr(self.object_list, 'ordered', None)
|
||||
if ordered is not None and not ordered:
|
||||
obj_list_repr = (
|
||||
'{} {}'.format(self.object_list.model, self.object_list.__class__.__name__)
|
||||
if hasattr(self.object_list, 'model')
|
||||
else '{!r}'.format(self.object_list)
|
||||
)
|
||||
warnings.warn(
|
||||
'Pagination may yield inconsistent results with an unordered '
|
||||
'object_list: {!r}'.format(self.object_list),
|
||||
'object_list: {}.'.format(obj_list_repr),
|
||||
UnorderedObjectListWarning,
|
||||
stacklevel=3
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user