Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #3153 -- newforms 'label' argument now can contain wacky charac…

…ters. Thanks, dswistowski

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4223 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit cd394a246aa32e5ce15b0643203b7bfdeb703eb6 1 parent bce9f65
Adrian Holovaty authored December 17, 2006
2  django/newforms/fields.py
@@ -34,6 +34,8 @@ class Field(object):
34 34
     creation_counter = 0
35 35
 
36 36
     def __init__(self, required=True, widget=None, label=None):
  37
+        if label is not None:
  38
+            label = smart_unicode(label)
37 39
         self.required, self.label = required, label
38 40
         widget = widget or self.widget
39 41
         if isinstance(widget, type):
8  tests/regressiontests/forms/tests.py
@@ -2062,6 +2062,14 @@
2062 2062
 <li>Password1: <input type="password" name="password1" /></li>
2063 2063
 <li>Password (again): <input type="password" name="password2" /></li>
2064 2064
 
  2065
+A label can be a Unicode object or a bytestring with special characters.
  2066
+>>> class UserRegistration(Form):
  2067
+...    username = CharField(max_length=10, label='ŠĐĆŽćžšđ')
  2068
+...    password = CharField(widget=PasswordInput, label=u'\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111')
  2069
+>>> p = UserRegistration(auto_id=False)
  2070
+>>> p.as_ul()
  2071
+u'<li>\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111: <input type="text" name="username" maxlength="10" /></li>\n<li>\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111: <input type="password" name="password" /></li>'
  2072
+
2065 2073
 # Forms with prefixes #########################################################
2066 2074
 
2067 2075
 Sometimes it's necessary to have multiple forms display on the same HTML page,

0 notes on commit cd394a2

Please sign in to comment.
Something went wrong with that request. Please try again.