Ticket #4804: unicode_in_oldform_choices.2.patch
File unicode_in_oldform_choices.2.patch, 1.7 KB (added by , 17 years ago) |
---|
-
django/oldforms/__init__.py
3 3 from django.utils.html import escape 4 4 from django.conf import settings 5 5 from django.utils.translation import ugettext, ungettext 6 from django.utils.encoding import smart_unicode, force_unicode , smart_str6 from django.utils.encoding import smart_unicode, force_unicode 7 7 8 8 FORM_FIELD_ID_PREFIX = 'id_' 9 9 … … 502 502 503 503 def isValidChoice(self, data, form): 504 504 str_data = smart_unicode(data) 505 str_choices = [smart_ str(item[0]) for item in self.choices]505 str_choices = [smart_unicode(item[0]) for item in self.choices] 506 506 if str_data not in str_choices: 507 507 raise validators.ValidationError, ugettext("Select a valid choice; '%(data)s' is not in %(choices)s.") % {'data': str_data, 'choices': str_choices} 508 508 -
tests/modeltests/manipulators/models.py
54 54 55 55 # Attempt to create an Album with an invalid musician. 56 56 >>> man.get_validation_errors(MultiValueDict({'name': ['Sallies Fforth'], 'musician': ['foo']})) 57 {'musician': [u"Select a valid choice; 'foo' is not in [ '','1']."]}57 {'musician': [u"Select a valid choice; 'foo' is not in [u'', u'1']."]} 58 58 59 59 # Attempt to create an Album with an invalid release_date. 60 60 >>> man.get_validation_errors(MultiValueDict({'name': ['Sallies Fforth'], 'musician': ['1'], 'release_date': 'today'}))