contrib/admin giving duplicate option in select box for unique declared m2m relationship
|Reported by:||txomon||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I have been testing django's admin interface, and I detected a "bug".
I am using the attached code.
There are several problems, or what I think they are bugs.
In first place, I used an inline in the admin.py to make the m2m appear in the interface. I am using through for personal reasons.
When you launch the app, (you can actually do ./manage.py syncdb && ./manage.py runserver) and have a person, and start to add instruments, you will notice that you can select two times the same (thought the unique_together property in the Relationship models).
In my opinion, that shouldn't be happening, as if you have marked it as unique, once selected, shouldn't give possibility to introduce once more that value. So I would ask for updating the widget (I am told that this is called like that) to dinamically update the select boxes to avoid giving duplicates option in unique m2m relationships. Screenshot attached.
When I saw that, I tried then to solve this by putting in the admin,py PersonAdmin, InstrumentAdmin, etc. the filter_horizontal property for making imposible with that method to insert duplicates. And I found that Instruments didn't had the reverse dependency. I asked in #django which was the name of the reverse dependency field (and also checked in shell) that it was named person_set (in Instrument, Post and Email).
I putted a line in each ModelAdmin to make a filter_horizontal for those fields, but it failed to recognise the person_set in the reversed ones.
Don't doubt asking me to explain once more or give details if you don't understand me.
Change History (4)
comment:1 Changed 4 years ago by
|Patch needs improvement:||unset|
|Status:||new → closed|
|Triage Stage:||Unreviewed → Someday/Maybe|