﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
27495	MultipleChoiceField isn't working with options longer than 1 character	Mario Härtwig	nobody	"The MultipleChoiceField doesn't seem to work it the name of the option in the choices list is longer than one character. If the options specified in the choices list are longer, the selected values cannot be restored after the form has been saved. 
{{{
(('1', 'foo'),
  ('b', 'bar'),)
}}}

works whereas
{{{
(('foo', 'foo'),
  ('bar, 'bar'),)
}}}

The values are saved as a string inside the database (e.g. ""['foo', 'bar']"").  The problem seems to be line [https://github.com/django/django/blob/master/django/forms/widgets.py#L564 Line 564 in forms/widgets.py]. This line tries to convert the array-like string from the database to an array without deserializing it before.

The string ""['foo', 'bar']"", for instance, is converted to {'o', ' ', 'a', ""'"", 'b', 'r', ']', ',', 'f', '['}.

I've created a [https://github.com/mhaertwig/django/commit/f3c1566173435cebf9bf55820ab3e4e63eea0518 fix] that solves the issue and I could create a pull request. However, I'm wondering if there shouldn't be some kind of deserialization of the array-like string before. And why isn't the array stored in a JSON strucure within the database (with double quotes). Am I missing something?"	Bug	closed	Forms	1.10	Normal	needsinfo	MultipleChoiceField		Unreviewed	0	0	0	0	0	0
