Opened 16 years ago
Closed 16 years ago
#7665 closed (duplicate)
User change list filters disappear in newforms-admin if a model has a OneToOneField to User
Reported by: | Wayne K. Werner | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | newforms-admin |
Severity: | 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
If I create a test project, with the bare minimum to connect to the default admin site and go to the user change list, the is_staff and is_superuser filters show up fine. If I now add a simple test app, with a single model, and that model has a OneToOneField to auth.User, then the filters do not show up in the admin change list for User.
I noticed this today after svn up to the tip r7857. I believe (but can't be positive) this was working before the holiday r7834.
# this works class TestModel(models.Model): pass # the is staff and is superuser models disappear from the admin class TestModel(models.Model): user = models.OneToOneField(User)
Change History (3)
comment:1 by , 16 years ago
comment:2 by , 16 years ago
Hmmm... one final comment... this function is identical to the one in trunk at line 587
comment:3 by , 16 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
This is really a duplicate of #2145 I think. Model inheritance utilises one to one relationships and currently the code doesn't allow filters to work for those. Changing line 87 to just
if self.list_filter:
works for me currently.
I believe this must affect all model change lists in admin:
In admin.views.main.py
I think the problem is the test at line 87. In the absence of any comments, I have no idea what this is trying to prevent. I can't see any good reason to restrict a model that is one to one referenced from another model from having filters.
Also, if I add the filter query (for instance,
?is_staff__exact=1
) to the url, the filtering works just fine.