#22569 closed Bug (fixed)
lookup_allowed fails to consider dynamic list_filter
| Reported by: | Owned by: | Sarah Boyce | |
|---|---|---|---|
| Component: | contrib.admin | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | contact@…, Sarah Boyce | Triage Stage: | Ready for checkin |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Currently, lookup_allowed iterates over self.list_filter to determine valid params. This is technically incorrect since the introduction of get_list_filter() on ModelAdmin in 1.5, because it is possible to define a ModelAdmin such that self.list_filter is () but get_list_filter yields SimpleListFilter classes.
To correct it, the above code would need to change from:
for filter_item in self.list_filter:
to
for filter_item in self.get_list_filter(request):
The problem is that now lookup_allowed needs to accept request so that it can pass it back to get_list_filter
In Django itself, that's actually reasonably acceptable as a change, because it's used infrequently - the only place it's actually used is in ChangeList.get_filters, which has access to the request. However, it is overridden in the wild without accept *args, **kwargs, so it'd not be easy to provide a clean upgrade path.
Change History (13)
comment:1 by , 12 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|---|
| Type: | Uncategorized → Bug |
comment:3 by , 10 years ago
| Cc: | added |
|---|
comment:4 by , 8 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:5 by , 8 years ago
| Has patch: | set |
|---|
comment:6 by , 8 years ago
| Patch needs improvement: | set |
|---|
comment:7 by , 4 years ago
| Owner: | removed |
|---|---|
| Status: | assigned → new |
comment:8 by , 3 years ago
| Cc: | added |
|---|
comment:9 by , 3 years ago
| Owner: | set to |
|---|---|
| Patch needs improvement: | unset |
| Status: | new → assigned |
comment:10 by , 3 years ago
| Patch needs improvement: | set |
|---|
comment:11 by , 3 years ago
| Patch needs improvement: | unset |
|---|
comment:12 by , 3 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
https://github.com/django/django/pull/8856