#7738 closed (fixed)
[newforms-admin] defaults for ManyToManyFields are broken on add page
Reported by: | John Shaffer | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Keywords: | selectmultiple, forms, admin | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In trunk, /app/model/add/?options=12, where options is a ManyToManyField, works as expected: the Option with a pk of 12 is selected. In newforms-admin, it is interpreted as if the querystring had been options=1,2
: the Options with pks of 1 and 2 are selected.
Attachments (1)
Change History (7)
comment:1 by , 16 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 16 years ago
milestone: | → 1.0 |
---|
comment:3 by , 16 years ago
Keywords: | selectmultiple forms admin added |
---|---|
Version: | newforms-admin → SVN |
Just a note here since probably I was a bit drunk when I wrote the comment above: the widget is SelectMultiple
obviously and what expects an iterable object is the choices
attribute of render()
.
comment:4 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
by , 16 years ago
Patch for when exception is caught, f would be undefined.
Note:
See TracTickets
for help on using tickets.
The problem described here belongs to this line: http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/options.py#L501
Actually, the
initial_data
for model forms onSelectMultipleWidget
expects an iterable object like a list or tuple for selecting the choices, while instead we're passing a string - i.e. "12" - that get then divided in in "1" and "2". I thought this could be changed in something likestring.split(',')
but I can see this behaviour is not documented anywhere, so maybe some core dev has a better idea (or maybe this should be marked as wontfix?).