However, if also emits this warning if passed a queryset which is
guaranteed to be empty, for instance Article.objects.none()
Working around this warning involves doing a bizarre
Article.objects.none().order_by('id')
I believe there can be legitimate usecases for passing a .none() queryset
to a paginator, for instance if a user's permissions are such that we
restrict the objects they can view to the empty queryset.
--
Ticket URL: <https://code.djangoproject.com/ticket/28917>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => assigned
* owner: nobody => Junji Wei
--
Ticket URL: <https://code.djangoproject.com/ticket/28917#comment:1>
* type: Bug => Cleanup/optimization
* component: Generic views => Core (Other)
* stage: Unreviewed => Accepted
Old description:
> Paginator (sanely!) does a check to verify that the queryset it is passed
> is ordered, and if it isn't, shows a warning.
>
> However, if also emits this warning if passed a queryset which is
> guaranteed to be empty, for instance Article.objects.none()
>
> Working around this warning involves doing a bizarre
> Article.objects.none().order_by('id')
>
> I believe there can be legitimate usecases for passing a .none() queryset
> to a paginator, for instance if a user's permissions are such that we
> restrict the objects they can view to the empty queryset.
New description:
`Paginator` shows a warning if it receives an unordered queryset.
However, if also emits this warning if passed a queryset which is
guaranteed to be empty, for instance `Article.objects.none()`.
Working around this warning involves doing a bizarre
`Article.objects.none().order_by('id')`
I believe there can be legitimate usecases for passing a `.none()`
queryset to a paginator, for instance if a user's permissions are such
that we restrict the objects they can view to the empty queryset.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/28917#comment:2>
Comment (by Junji Wei):
PR https://github.com/django/django/pull/9479
--
Ticket URL: <https://code.djangoproject.com/ticket/28917#comment:3>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/28917#comment:4>
* needs_better_patch: 0 => 1
Comment:
Discussion on PR led to conclusion that this could be resolved by having
`QuerySet.ordered` return `True` when the queryset is empty. (Something is
ordered if it always returns the same sequence. An empty QuerySet does,
i.e. `[]`)
Marking as "Patch needs improvement" pending that change.
--
Ticket URL: <https://code.djangoproject.com/ticket/28917#comment:5>
* owner: Junji Wei => (none)
* needs_better_patch: 1 => 0
* status: assigned => new
* stage: Accepted => Ready for checkin
Comment:
[https://github.com/django/django/pull/10184 New PR] from Josh Schneier.
Minor change to docstring suggested but otherwise, looks good.
--
Ticket URL: <https://code.djangoproject.com/ticket/28917#comment:6>
* owner: (none) => Tim Graham <timograham@…>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"4d48ddd8f93800a80330ec1dee7b7d4afe6ea95a" 4d48ddd]:
{{{
#!CommitTicketReference repository=""
revision="4d48ddd8f93800a80330ec1dee7b7d4afe6ea95a"
Fixed #28917 -- Prevented Paginator's unordered warning on EmptyQuerySet.
Thanks carltongibson for the idea and weijunji for the initial patch.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28917#comment:7>