[newforms-admin] defaults for ManyToManyFields are broken on add page
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)
- 7738.diff
(542 bytes
) - added by gkelly 17 years ago.
- Patch for when exception is caught, f would be undefined.
Download all attachments as:
.zip
Change History
(7)
| Triage Stage: |
Unreviewed → Accepted
|
| Keywords: |
selectmultiple forms admin added
|
| Version: |
newforms-admin → SVN
|
| Resolution: |
→ fixed
|
| Status: |
new → closed
|
The problem described here belongs to this line: http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/options.py#L501
Actually, the
initial_datafor model forms onSelectMultipleWidgetexpects 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?).