Code

Opened 18 months ago

Closed 17 months ago

Last modified 17 months ago

#19175 closed Bug (wontfix)

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

Reported by: txomon 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 txomon 18 months ago.
code using django 1.4
django-admin-bug.png (72.3 KB) - added by txomon 18 months 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)

Changed 18 months ago by txomon

code using django 1.4

Changed 18 months ago by txomon

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

comment:1 Changed 17 months ago by mattaustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed
  • Triage Stage changed from Unreviewed to Someday/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 Changed 17 months ago by txomon

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.