mirror of
https://github.com/django/django.git
synced 2025-10-26 07:06:08 +00:00
Fixed #8746: Check data in raw_id_fields more closely. Thanks, dgouldin
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10233 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -760,6 +760,7 @@ class ModelMultipleChoiceField(ModelChoiceField):
|
||||
'list': _(u'Enter a list of values.'),
|
||||
'invalid_choice': _(u'Select a valid choice. %s is not one of the'
|
||||
u' available choices.'),
|
||||
'invalid_pk_value': _(u'"%s" is not a valid value for a primary key.')
|
||||
}
|
||||
|
||||
def __init__(self, queryset, cache_choices=False, required=True,
|
||||
@@ -782,6 +783,8 @@ class ModelMultipleChoiceField(ModelChoiceField):
|
||||
obj = self.queryset.get(pk=val)
|
||||
except self.queryset.model.DoesNotExist:
|
||||
raise ValidationError(self.error_messages['invalid_choice'] % val)
|
||||
except ValueError:
|
||||
raise ValidationError(self.error_messages['invalid_pk_value'] % val)
|
||||
else:
|
||||
final_values.append(obj)
|
||||
return final_values
|
||||
|
||||
Reference in New Issue
Block a user