diff --git a/django/forms/models.py b/django/forms/models.py
index 70f0631..711cac4 100644
a
|
b
|
class ModelMultipleChoiceField(ModelChoiceField):
|
781 | 781 | return [] |
782 | 782 | if not isinstance(value, (list, tuple)): |
783 | 783 | raise ValidationError(self.error_messages['list']) |
784 | | final_values = [] |
785 | | for val in value: |
| 784 | for pk in value: |
786 | 785 | try: |
787 | | obj = self.queryset.get(pk=val) |
788 | | except self.queryset.model.DoesNotExist: |
789 | | raise ValidationError(self.error_messages['invalid_choice'] % val) |
| 786 | self.queryset.filter(pk=pk) |
790 | 787 | except ValueError: |
791 | | raise ValidationError(self.error_messages['invalid_pk_value'] % val) |
792 | | else: |
793 | | final_values.append(obj) |
794 | | return final_values |
| 788 | raise ValidationError(self.error_messages['invalid_pk_value'] % pk) |
| 789 | qs = self.queryset.filter(pk__in=value) |
| 790 | pks = set([force_unicode(o.pk) for o in qs]) |
| 791 | for val in value: |
| 792 | if force_unicode(val) not in pks: |
| 793 | raise ValidationError(self.error_messages['invalid_choice'] % val) |
| 794 | return qs |