Opened 8 years ago

Closed 8 years ago

#28185 closed Bug (duplicate)

ModelAdmin.lookup_allowed() fails to consider dynamic list_filter

Reported by: IT Management Owned by: nobody
Component: contrib.admin Version: 1.11
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If I define dynamic filters using "get_list_filter" method in my Admin class and try to use any of them, a DisallowedModelAdminLookup exception is raised.

I thing there is an error in file "django.contrib.admin.options.py" in class "BaseModelAdmin" and method "lookup_allowed".

class BaseModelAdmin(six.with_metaclass(forms.MediaDefiningClass)):
  def lookup_allowed(self, lookup, value):
--cut--
    for filter_item in self.list_filter:
--cut--

I thing the right form is:

class BaseModelAdmin(six.with_metaclass(forms.MediaDefiningClass)):
  def lookup_allowed(self, lookup, value):
--cut--
    for filter_item in self.get_list_filter():
--cut--

Change History (1)

comment:1 by Tim Graham, 8 years ago

Needs documentation: set
Resolution: duplicate
Status: newclosed
Summary: Probably an error in BaseModelAdmin#lookup_allowedModelAdmin.lookup_allowed() fails to consider dynamic list_filter

Duplicate of #22569.

Note: See TracTickets for help on using tickets.
Back to Top