From 87d8976faee7b07a30ce1bd844b2b6178c3a3328 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Tue, 10 Jul 2007 12:03:36 +0000 Subject: [PATCH] Fixed #4804 -- Fixed a problem when validating choice lists with non-ASCII data. Thanks, django@vonposer.de. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5642 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/oldforms/__init__.py | 4 ++-- tests/modeltests/manipulators/models.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/django/oldforms/__init__.py b/django/oldforms/__init__.py index d0f9aca62a..a0f14cdcf2 100644 --- a/django/oldforms/__init__.py +++ b/django/oldforms/__init__.py @@ -3,7 +3,7 @@ from django.core.exceptions import PermissionDenied from django.utils.html import escape from django.conf import settings from django.utils.translation import ugettext, ungettext -from django.utils.encoding import smart_unicode, force_unicode, smart_str +from django.utils.encoding import smart_unicode, force_unicode FORM_FIELD_ID_PREFIX = 'id_' @@ -502,7 +502,7 @@ class SelectField(FormField): def isValidChoice(self, data, form): str_data = smart_unicode(data) - str_choices = [smart_str(item[0]) for item in self.choices] + str_choices = [smart_unicode(item[0]) for item in self.choices] if str_data not in str_choices: raise validators.ValidationError, ugettext("Select a valid choice; '%(data)s' is not in %(choices)s.") % {'data': str_data, 'choices': str_choices} diff --git a/tests/modeltests/manipulators/models.py b/tests/modeltests/manipulators/models.py index 7f1ff0e47b..46063828b9 100644 --- a/tests/modeltests/manipulators/models.py +++ b/tests/modeltests/manipulators/models.py @@ -54,7 +54,7 @@ True # Attempt to create an Album with an invalid musician. >>> man.get_validation_errors(MultiValueDict({'name': ['Sallies Fforth'], 'musician': ['foo']})) -{'musician': [u"Select a valid choice; 'foo' is not in ['', '1']."]} +{'musician': [u"Select a valid choice; 'foo' is not in [u'', u'1']."]} # Attempt to create an Album with an invalid release_date. >>> man.get_validation_errors(MultiValueDict({'name': ['Sallies Fforth'], 'musician': ['1'], 'release_date': 'today'}))