From e1cb961a9b7d6440cad468148ebcffc841ac81a3 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Thu, 13 Sep 2007 22:35:18 +0000 Subject: [PATCH] Fixed #5370 -- Allow lazy translations in ValidationError classes. Patch from James Bennett. git-svn-id: http://code.djangoproject.com/svn/django/trunk@6140 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/newforms/util.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/django/newforms/util.py b/django/newforms/util.py index 2bafc8d9c7..57995bebd0 100644 --- a/django/newforms/util.py +++ b/django/newforms/util.py @@ -1,5 +1,6 @@ from django.utils.html import escape from django.utils.encoding import smart_unicode, StrAndUnicode +from django.utils.functional import Promise def flatatt(attrs): """ @@ -47,7 +48,7 @@ class ValidationError(Exception): if isinstance(message, list): self.messages = ErrorList([smart_unicode(msg) for msg in message]) else: - assert isinstance(message, basestring), ("%s should be a basestring" % repr(message)) + assert isinstance(message, (basestring, Promise)), ("%s should be a basestring or lazy translation" % repr(message)) message = smart_unicode(message) self.messages = ErrorList([message])