Opened 5 years ago
Closed 5 years ago
#31851 closed Bug (needsinfo)
list_filter not working with foreign keys
| Reported by: | Tom Carrick | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.admin | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
From what I understand reading the docs, this should work, where author is a foreign key:
list_filter = ["author"]
But it silently fails, it just doesn't show on the page. However, if I specify the field, it works fine:
list_filter = ["author__name"]
Change History (3)
comment:1 by , 5 years ago
| Resolution: | → worksforme |
|---|---|
| Status: | new → closed |
comment:2 by , 5 years ago
| Resolution: | worksforme |
|---|---|
| Status: | closed → new |
This is definitely an issue. I think I've narrowed it down somewhat: the filter actually works, i.e. you can set the querystring manually and it filters correctly, but it doesn't show up on the admin change list page.
I think it's because the primary key of the related model is a CIEmailField, but I'm not sure, it's tricky to debug as there's no output.
comment:3 by , 5 years ago
| Resolution: | → needsinfo |
|---|---|
| Status: | new → closed |
It works for me also with a ForeignKey to model with CIEmailField as a primary key, e.g.
class Author(models.Model):
email = CIEmailField(primary_key=True)
Please provide a sample project that reproduces this issue.
Thanks for the report, however it works for me.