Ticket #8974: 8974.patch
File 8974.patch, 912 bytes (added by , 16 years ago) |
---|
-
django/forms/models.py
648 648 try: 649 649 key = self.to_field_name or 'pk' 650 650 value = self.queryset.get(**{key: value}) 651 except self.queryset.model.DoesNotExist:651 except (self.queryset.model.DoesNotExist, ValueError): 652 652 raise ValidationError(self.error_messages['invalid_choice']) 653 653 return value 654 654 … … 680 680 for val in value: 681 681 try: 682 682 obj = self.queryset.get(pk=val) 683 except self.queryset.model.DoesNotExist:683 except (self.queryset.model.DoesNotExist, ValueError): 684 684 raise ValidationError(self.error_messages['invalid_choice'] % val) 685 685 else: 686 686 final_values.append(obj)