I wonder if this is a case you want to catch and *not* warn about.
In my case, I'm doing a:
haves =
MyModel.objects.filter(foreign_relationship=4).order_by('foreign_relationship__value',
'common_key')
havenots = MyModel.objects.exclude(id__in=haves).order_by('common_key')
query = haves.union(havenots, all=True)
And I'm using this with a Paginator. The Paginator thinks the queries are
not ordered, but they actually are (right?) due to the all=True in the
union.
Is this a case the warning ought to handle and ignore?
The Django 1.11 source is:
def _check_object_list_is_ordered(self):
"""
Warn if self.object_list is unordered (typically a QuerySet).
"""
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: {}.'.format(obj_list_repr),
UnorderedObjectListWarning,
stacklevel=3
)
Should I file a bug?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/2d1dc6a6-35c1-48ac-afe3-d08cd4636990%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.