Opened 6 years ago

Closed 6 years ago

Last modified 6 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 Changed 6 years ago by 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()?

comment:2 Changed 6 years ago by Tim Graham

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

comment:3 in reply to:  1 Changed 6 years ago by Denise Mauldin

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