-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #29835 -- Made RelatedFieldListFilter respect ModelAdmin.ordering.
- Loading branch information
Showing
5 changed files
with
81 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -194,7 +194,11 @@ def expected_parameters(self): | |
return [self.lookup_kwarg, self.lookup_kwarg_isnull] | ||
|
||
def field_choices(self, field, request, model_admin): | ||
return field.get_choices(include_blank=False) | ||
ordering = () | ||
related_admin = model_admin.admin_site._registry.get(field.remote_field.model) | ||
if related_admin is not None: | ||
ordering = related_admin.get_ordering(request) | ||
return field.get_choices(include_blank=False, ordering=ordering) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
timgraham
Member
|
||
|
||
def choices(self, changelist): | ||
yield { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The same code should be used in RelatedOnlyFieldListFilter also.
It was however refactored and fixed in django 3.x versions.
Shouldn't it be fixed in 2.2.x version?