1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #18172 -- Made models with __iter__ usable in ModelMultipleChoiceField

Thanks to Patryk Zawadzki for the patch.
This commit is contained in:
Patryk Zawadzki
2012-12-19 19:12:08 +01:00
committed by Anssi Kääriäinen
parent abd0f304b1
commit 3989ce52ef
3 changed files with 33 additions and 2 deletions

View File

@@ -1033,6 +1033,8 @@ class ModelMultipleChoiceField(ModelChoiceField):
return qs
def prepare_value(self, value):
if hasattr(value, '__iter__') and not isinstance(value, six.text_type):
if (hasattr(value, '__iter__') and
not isinstance(value, six.text_type) and
not hasattr(value, '_meta')):
return [super(ModelMultipleChoiceField, self).prepare_value(v) for v in value]
return super(ModelMultipleChoiceField, self).prepare_value(value)