mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
[1.5.x] Fixed #17646 -- Added a get_list_filter() method to ModelAdmin. Thanks to rasca for the suggestion and to mateusgondim for the patch.
Backport of ae206d78f6
This commit is contained in:
@@ -665,6 +665,13 @@ class ModelAdmin(BaseModelAdmin):
|
||||
# Use only the first item in list_display as link
|
||||
return list(list_display)[:1]
|
||||
|
||||
def get_list_filter(self, request):
|
||||
"""
|
||||
Returns a sequence containing the fields to be displayed as filters in
|
||||
the right sidebar of the changelist page.
|
||||
"""
|
||||
return self.list_filter
|
||||
|
||||
def construct_change_message(self, request, form, formsets):
|
||||
"""
|
||||
Construct a change message from a changed object.
|
||||
@@ -1192,6 +1199,7 @@ class ModelAdmin(BaseModelAdmin):
|
||||
|
||||
list_display = self.get_list_display(request)
|
||||
list_display_links = self.get_list_display_links(request, list_display)
|
||||
list_filter = self.get_list_filter(request)
|
||||
|
||||
# Check actions to see if any are available on this changelist
|
||||
actions = self.get_actions(request)
|
||||
@@ -1202,7 +1210,7 @@ class ModelAdmin(BaseModelAdmin):
|
||||
ChangeList = self.get_changelist(request)
|
||||
try:
|
||||
cl = ChangeList(request, self.model, list_display,
|
||||
list_display_links, self.list_filter, self.date_hierarchy,
|
||||
list_display_links, list_filter, self.date_hierarchy,
|
||||
self.search_fields, self.list_select_related,
|
||||
self.list_per_page, self.list_max_show_all, self.list_editable,
|
||||
self)
|
||||
|
||||
Reference in New Issue
Block a user