Opened 11 years ago

Closed 11 years ago

#20833 closed Bug (invalid)

If there are choices more than 10 when using CheckboxSelectMultiple or SelectMultiple, different options from the original become selected.

Reported by: Naoya Niwa <mine@…> Owned by: nobody
Component: Forms Version: 1.4
Severity: Normal Keywords: MultipleChoiceField
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

MultipleChoiceField is stored in the database the data in serialized array like "[u'4', u'13']" . However, because the widget does not deserialize when reading it, the results shown is incorrect.

In version 1.4.5, the problem occurs in the 568 line and 548 line of "django/forms/widgets.py".

If one digit, for example, "[u'9']" is converted to "set([u"'", u'9', u', u', u'u'])" by "set([force_unicode(v) for v in value])", there is no problem in the process to match one by one index number.However, in the case of multi-digit numbers, and thus, for example, "[u'13']" is converted to "set([u"'", u'1', u'3', u', u', u'u'])", 1 and 3 in the zero-based index is selected.

Change History (3)

comment:1 by Tim Graham, 11 years ago

What database field are you using that stores data as a serialized array? It seems to me like to problem may be with that field and not with the forms layer.

comment:2 by Naoya Niwa <mine@…>, 11 years ago

I forgot to write. I'm using TextField.

comment:3 by Tim Graham, 11 years ago

Resolution: invalid
Status: newclosed

Consider using a ManyToManyField instead. I don't think this will work with TextField without some hacking.

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