Ticket #8746: 8746.diff
File 8746.diff, 1.6 KB (added by , 16 years ago) |
---|
-
django/forms/models.py
729 729 'list': _(u'Enter a list of values.'), 730 730 'invalid_choice': _(u'Select a valid choice. %s is not one of the' 731 731 u' available choices.'), 732 'invalid_pk_value': _(u'"%s" is not a valid value for a primary key.') 732 733 } 733 734 734 735 def __init__(self, queryset, cache_choices=False, required=True, … … 751 752 obj = self.queryset.get(pk=val) 752 753 except self.queryset.model.DoesNotExist: 753 754 raise ValidationError(self.error_messages['invalid_choice'] % val) 755 except ValueError: 756 raise ValidationError(self.error_messages['invalid_pk_value'] % val) 754 757 else: 755 758 final_values.append(obj) 756 759 return final_values -
tests/modeltests/model_forms/models.py
857 857 Traceback (most recent call last): 858 858 ... 859 859 ValidationError: [u'Enter a list of values.'] 860 >>> f.clean(['fail']) 861 Traceback (most recent call last): 862 ... 863 ValidationError: [u'"fail" is not a valid value for a primary key.'] 860 864 861 865 # Add a Category object *after* the ModelMultipleChoiceField has already been 862 866 # instantiated. This proves clean() checks the database during clean() rather