Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#29835 closed Bug (fixed)

Make RelatedFieldListFilter respect ModelAdmin.ordering

Reported by: Brillgen Developers Owned by: Hasan Ramezani
Component: contrib.admin Version: dev
Severity: Normal Keywords: filter
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 Brillgen Developers)

Django admin class provides an ordering field which overrides the model meta ordering/defines the order in which objects should be displayed. This is respected by the new autocomplete field in foreign keys.

However the django admin list filter does not use the ordering from the related admin (if present) and only relies on the model meta ordering. This has a performance impact also as the model meta ordering applies to all queries, not just those for django admin.

Change History (7)

comment:1 by Brillgen Developers, 6 years ago

Description: modified (diff)

comment:2 by Carlton Gibson, 6 years ago

Triage Stage: UnreviewedAccepted
Version: 2.0master

This looks reasonable. `RelatedFieldListFilter.field_choices()` goes straight via `Field.get_choices()`. It should probably make a detour through `BaseModelAdmin.get_field_queryset()`.

comment:3 by Paulo, 6 years ago

Owner: changed from nobody to Paulo
Status: newassigned

comment:4 by Hasan Ramezani, 5 years ago

Has patch: set
Last edited 5 years ago by Tim Graham (previous) (diff)

comment:5 by Hasan Ramezani, 5 years ago

Owner: changed from Paulo to Hasan Ramezani

comment:6 by Tim Graham <timograham@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In 6d4e5fe:

Fixed #29835 -- Made RelatedFieldListFilter respect ModelAdmin.ordering.

comment:7 by Tim Graham, 5 years ago

Summary: list_filter does not follow admin ordering, only model metaMake RelatedFieldListFilter respect ModelAdmin.ordering
Note: See TracTickets for help on using tickets.
Back to Top