Make RelatedFieldListFilter respect ModelAdmin.ordering
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)
Description: |
modified (diff)
|
Triage Stage: |
Unreviewed → Accepted
|
Version: |
2.0 → master
|
Owner: |
changed from nobody to Paulo
|
Status: |
new → assigned
|
Owner: |
changed from Paulo to Hasan Ramezani
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
Summary: |
list_filter does not follow admin ordering, only model meta → Make RelatedFieldListFilter respect ModelAdmin.ordering
|
This looks reasonable. `RelatedFieldListFilter.field_choices()` goes straight via `Field.get_choices()`. It should probably make a detour through `BaseModelAdmin.get_field_queryset()`.