1 | Index: forms/models.py
|
---|
2 | ===================================================================
|
---|
3 | --- forms/models.py (revision 9173)
|
---|
4 | +++ forms/models.py (working copy)
|
---|
5 | @@ -647,6 +647,11 @@
|
---|
6 | if value in EMPTY_VALUES:
|
---|
7 | return None
|
---|
8 | try:
|
---|
9 | + int(value)
|
---|
10 | + except:
|
---|
11 | + raise ValidationError(self.error_messages['invalid_choice'])
|
---|
12 | +
|
---|
13 | + try:
|
---|
14 | key = self.to_field_name or 'pk'
|
---|
15 | value = self.queryset.get(**{key: value})
|
---|
16 | except self.queryset.model.DoesNotExist:
|
---|
17 | @@ -680,6 +685,11 @@
|
---|
18 | final_values = []
|
---|
19 | for val in value:
|
---|
20 | try:
|
---|
21 | + int(val)
|
---|
22 | + except:
|
---|
23 | + raise ValidationError(self.error_messages['invalid_choice'] % val)
|
---|
24 | +
|
---|
25 | + try:
|
---|
26 | obj = self.queryset.get(pk=val)
|
---|
27 | except self.queryset.model.DoesNotExist:
|
---|
28 | raise ValidationError(self.error_messages['invalid_choice'] % val)
|
---|