Opened 5 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 Changed 5 years ago by Brillgen Developers

Description: modified (diff)

comment:2 Changed 5 years ago by Carlton Gibson

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 Changed 5 years ago by Paulo

Owner: changed from nobody to Paulo
Status: newassigned

comment:4 Changed 5 years ago by Hasan Ramezani

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

comment:5 Changed 5 years ago by Hasan Ramezani

Owner: changed from Paulo to Hasan Ramezani

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

Resolution: fixed
Status: assignedclosed

In 6d4e5fe:

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

comment:7 Changed 5 years ago by Tim Graham

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