#21431 closed Bug (fixed)
Django 1.6 GenericRelation admin list_filter regression
Reported by: | stephenmcd | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 1.6 |
Severity: | Release blocker | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Previously in 1.5 it was possible to have a model A with a GenericRelation field to a model B that had a ForeignKey to model C, and use the BC path in A's admin list_filter.
In 1.6 this fails in django.contrib.admin.util.get_model_from_relation where the model on the wrong side of the relationship is returned, when the correct model is available via the parent_model attribute.
I've created a fix and test case here: https://github.com/django/django/pull/1913
Although as discussed, the fix should probably be different.
Change History (4)
comment:1 by , 11 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 11 years ago
Thanks akaariai - I can confirm the above patch resolves the issue in Mezzanine.
comment:3 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
A proposed patch for 1.6.x in https://github.com/akaariai/django/commit/c895dd39ae4e7687b57ff01ecfcc27caf70323ed.
There are two issues I am concerned with:
In general the admin code should be DRYed up a little when it comes to relation path generation.
For master the elif branches in admin/util.py could be removed, it shouldn't be hit at all, but for 1.6 could cause more regressions (shouldn't, but can't assert it doesn't).