Django

Code

Changeset 4223

Show
Ignore:
Timestamp:
12/17/06 13:04:03 (2 years ago)
Author:
adrian
Message:

Fixed #3153 -- newforms 'label' argument now can contain wacky characters. Thanks, dswistowski

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/newforms/fields.py

    r4218 r4223  
    3535 
    3636    def __init__(self, required=True, widget=None, label=None): 
     37        if label is not None: 
     38            label = smart_unicode(label) 
    3739        self.required, self.label = required, label 
    3840        widget = widget or self.widget 
  • django/trunk/tests/regressiontests/forms/tests.py

    r4218 r4223  
    20632063<li>Password (again): <input type="password" name="password2" /></li> 
    20642064 
     2065A 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() 
     2071u'<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 
    20652073# Forms with prefixes ######################################################### 
    20662074