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:14:22 +0100 |
| commit | 8a9c8bb90736451e6bdea82723cbb23a695146fb (patch) | |
| tree | 4f13cdb15c6c6627e5bc31e8af6af65295c8dd74 /django | |
| parent | 6d20a80d986848da5944904c7f91d6e002701ef1 (diff) | |
Fixed #21568 -- Added missing ModelMultipleChoiceField to_python method
Thanks dibrovsd at gmail.com for the report and Simon Charette
for the review.
Diffstat (limited to 'django')
| -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 5c2c77cbf2..2d068eba1e 100644 --- a/django/forms/models.py +++ b/django/forms/models.py @@ -1175,6 +1175,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') |
