Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#19175 closed Bug (wontfix)

contrib/admin giving duplicate option in select box for unique declared m2m relationship

Reported by: Javier Domingo Cansino Owned by: nobody
Component: contrib.admin Version: 1.4
Severity: Normal Keywords:
Cc: javierdo1@… Triage Stage: Someday/Maybe
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: yes

Description

Hi,

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.

Attachments (2)

lmb97-django-web-5bdd052.zip (6.7 KB ) - added by Javier Domingo Cansino 12 years ago.
code using django 1.4
django-admin-bug.png (72.3 KB ) - added by Javier Domingo Cansino 12 years ago.
Demonstration on how to select two times the same value in a m2m unique declared relationship

Download all attachments as: .zip

Change History (4)

by Javier Domingo Cansino, 12 years ago

code using django 1.4

by Javier Domingo Cansino, 12 years ago

Attachment: django-admin-bug.png added

Demonstration on how to select two times the same value in a m2m unique declared relationship

comment:1 by Matt Austin, 12 years ago

Resolution: wontfix
Status: newclosed
Triage Stage: UnreviewedSomeday/Maybe

I believe this bug is a feature request for a widget who's choices would be altered using JavaScript as the user adds/selects new related objects from the inline admin formset.

However this would be very complicated to implement and since the data is still validated when POSTed, we're marking this as a won't fix.

comment:2 by Javier Domingo Cansino, 12 years ago

Ok, thank you! I suppose that triage stage "Someday/maybe" is how you mark feature requests...

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