Ticket #4804: unicode_in_oldform_choices.2.patch

File unicode_in_oldform_choices.2.patch, 1.7 KB (added by django@…, 17 years ago)

Better fix, patches the modeltests accordingly

  • django/oldforms/__init__.py

     
    33from django.utils.html import escape
    44from django.conf import settings
    55from django.utils.translation import ugettext, ungettext
    6 from django.utils.encoding import smart_unicode, force_unicode, smart_str
     6from django.utils.encoding import smart_unicode, force_unicode
    77
    88FORM_FIELD_ID_PREFIX = 'id_'
    99
     
    502502
    503503    def isValidChoice(self, data, form):
    504504        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]
    506506        if str_data not in str_choices:
    507507            raise validators.ValidationError, ugettext("Select a valid choice; '%(data)s' is not in %(choices)s.") % {'data': str_data, 'choices': str_choices}
    508508
  • tests/modeltests/manipulators/models.py

     
    5454
    5555# Attempt to create an Album with an invalid musician.
    5656>>> 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']."]}
    5858
    5959# Attempt to create an Album with an invalid release_date.
    6060>>> man.get_validation_errors(MultiValueDict({'name': ['Sallies Fforth'], 'musician': ['1'], 'release_date': 'today'}))
Back to Top