One-to-one relation causes inappropriate filtering of other relations
When a model has a OneToOneField pointing at it from another model, and that model has limit_choices_to set, then any related-object-selection displayed for that model will apply the limit_choices_to, regardless of whether the popup is being displayed to select an object for the relation which has limit_choices_to set.
Since this is somewhat hard to explain in words, I'll attach a minimal sample project which demonstrates the issue.
Attachments
(1)
- o2ofail.tgz
(1.1 KB
) - added by James Bennett 17 years ago.
- Minimal test-case app; see instructions in models.py.
Download all attachments as:
.zip
Change History
(6)
| Triage Stage: |
Unreviewed → Accepted
|
| Owner: |
changed from nobody to Brian Rosner
|
| Status: |
new → assigned
|
| Resolution: |
→ fixed
|
| Status: |
assigned → closed
|
The source of the bug, incidentally, is almost certainly line 240 of
contrib/admin/views/main.py; I'm just not sure yet how to fix this so that it "knows" which model you were adding/editing when you clicked for the popup (since it should only applylimit_choices_towhen adding/editing the model which has theOneToOneField).