Opened 4 years ago

Closed 4 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 Mariusz Felisiak, 4 years ago

Resolution: worksforme
Status: newclosed

Thanks for the report, however it works for me.

comment:2 by Tom Carrick, 4 years ago

Resolution: worksforme
Status: closednew

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 Mariusz Felisiak, 4 years ago

Resolution: needsinfo
Status: newclosed

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.

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