From 6d4e5feb79f7eabe8a0c7c4b87f25b1a7f87ca0b Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Fri, 19 Oct 2018 15:41:29 +0200 Subject: Fixed #29835 -- Made RelatedFieldListFilter respect ModelAdmin.ordering. --- django/db/models/fields/__init__.py | 4 ++-- django/db/models/fields/reverse_related.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'django/db/models/fields') diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 04c7f002bc..fc4966c8b7 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -807,7 +807,7 @@ class Field(RegisterLookupMixin): return return_None return str # return empty string - def get_choices(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH, limit_choices_to=None): + def get_choices(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH, limit_choices_to=None, ordering=()): """ Return choices with a default blank choices included, for use as choices for this field. @@ -123,7 +123,7 @@ class ForeignObjectRel(FieldCacheMixin): initially for utilization by RelatedFieldListFilter. """ return (blank_choice if include_blank else []) + [ - (x.pk, str(x)) for x in self.related_model._default_manager.all() + (x.pk, str(x)) for x in self.related_model._default_manager.order_by(*ordering) ] def is_hidden(self): -- cgit v1.3