Opened 5 weeks ago

Last modified 4 weeks ago

#28917 assigned Cleanup/optimization

Remove paginator's unordered queryset warning for a .none() queryset

Reported by: Jeremy Lainé Owned by: Junji Wei
Component: Core (Other) Version: 2.0
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

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.

Change History (4)

comment:1 Changed 4 weeks ago by Junji Wei

Owner: changed from nobody to Junji Wei
Status: newassigned

comment:2 Changed 4 weeks ago by Tim Graham

Component: Generic viewsCore (Other)
Description: modified (diff)
Summary: Paginator shows ordering warning on an empty .none() querysetRemove paginator's unordered queryset warning for a .none() queryset
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

comment:4 Changed 4 weeks ago by Sergey Fedoseev

Has patch: set
Note: See TracTickets for help on using tickets.
Back to Top