diff options
| author | Claude Paroz <claude@2xlibre.net> | 2013-12-06 14:40:51 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2013-12-07 10:21:05 +0100 |
| commit | 34c4b93c84e86665d66d0b31da8e30fd581d5b5f (patch) | |
| tree | 18455e7a4978c7c06aa74fbbd85b501080a851aa /django/forms | |
| parent | 7d75a33331c971194bd07143aa8ff4b491f5c693 (diff) | |
[1.6.x] Fixed #21568 -- Added missing ModelMultipleChoiceField to_python method
Thanks dibrovsd at gmail.com for the report and Simon Charette
for the review.
Backport of 8a9c8bb90 from master.
Diffstat (limited to 'django/forms')
| -rw-r--r-- | django/forms/models.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/django/forms/models.py b/django/forms/models.py index 5c4fe4bbdf..15c0015b89 100644 --- a/django/forms/models.py +++ b/django/forms/models.py @@ -1167,6 +1167,12 @@ class ModelMultipleChoiceField(ModelChoiceField): msg = _('Hold down "Control", or "Command" on a Mac, to select more than one.') self.help_text = string_concat(self.help_text, ' ', msg) + def to_python(self, value): + if not value: + return [] + to_py = super(ModelMultipleChoiceField, self).to_python + return [to_py(val) for val in value] + def clean(self, value): if self.required and not value: raise ValidationError(self.error_messages['required'], code='required') |
