Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#28220 closed Cleanup/optimization (wontfix)

contrib.auth.models Group should have a default ordering to prevent UnorderedObjectListWarning

Reported by: Denise Mauldin Owned by: nobody
Component: contrib.auth Version: 1.11
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Since contrib.auth.models Group doesn't have an ordering default, any selection using Group and filter causes an UnorderedObjectListWarning in Django 1.11.

Group.objects.filter(user=user.id)

Can a default ordering be set somehow to prevent this warning?

Thanks,
Denise

Change History (3)

comment:1 by Simon Charette, 7 years ago

Defining a default ordering coud break existing application and would most likely require a migration for the _meta.ordering change.

The only paginated use of Group's manager is through GroupAdmin which is already ordered by name.

Is there a reason you can't explicitly specify an ordering when exposing groups through a paginated view by using order_by()?

comment:2 by Tim Graham, 7 years ago

Component: Uncategorizedcontrib.auth
Resolution: wontfix
Status: newclosed
Type: UncategorizedCleanup/optimization

in reply to:  1 comment:3 by Denise Mauldin, 7 years ago

Will do. Just was hoping there was a faster way than updating all of our code. Thanks.

Replying to Simon Charette:

Defining a default ordering coud break existing application and would most likely require a migration for the _meta.ordering change.

The only paginated use of Group's manager is through GroupAdmin which is already ordered by name.

Is there a reason you can't explicitly specify an ordering when exposing groups through a paginated view by using order_by()?

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