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:
		
				
					committed by
					
						 Anssi Kääriäinen
						Anssi Kääriäinen
					
				
			
			
				
	
			
			
			
						parent
						
							abd0f304b1
						
					
				
				
					commit
					3989ce52ef
				
			| @@ -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) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user