mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[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.
			
			
This commit is contained in:
		| @@ -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') | ||||
|   | ||||
		Reference in New Issue
	
	Block a user