Fixed #3153 -- newforms 'label' argument now can contain wacky characters. Thanks, dswistowski
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4223 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
bce9f65c61
commit
cd394a246a
|
@ -34,6 +34,8 @@ class Field(object):
|
||||||
creation_counter = 0
|
creation_counter = 0
|
||||||
|
|
||||||
def __init__(self, required=True, widget=None, label=None):
|
def __init__(self, required=True, widget=None, label=None):
|
||||||
|
if label is not None:
|
||||||
|
label = smart_unicode(label)
|
||||||
self.required, self.label = required, label
|
self.required, self.label = required, label
|
||||||
widget = widget or self.widget
|
widget = widget or self.widget
|
||||||
if isinstance(widget, type):
|
if isinstance(widget, type):
|
||||||
|
|
|
@ -2062,6 +2062,14 @@ underscores converted to spaces, and the initial letter capitalized.
|
||||||
<li>Password1: <input type="password" name="password1" /></li>
|
<li>Password1: <input type="password" name="password1" /></li>
|
||||||
<li>Password (again): <input type="password" name="password2" /></li>
|
<li>Password (again): <input type="password" name="password2" /></li>
|
||||||
|
|
||||||
|
A label can be a Unicode object or a bytestring with special characters.
|
||||||
|
>>> class UserRegistration(Form):
|
||||||
|
... username = CharField(max_length=10, label='ŠĐĆŽćžšđ')
|
||||||
|
... password = CharField(widget=PasswordInput, label=u'\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111')
|
||||||
|
>>> p = UserRegistration(auto_id=False)
|
||||||
|
>>> p.as_ul()
|
||||||
|
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>'
|
||||||
|
|
||||||
# Forms with prefixes #########################################################
|
# Forms with prefixes #########################################################
|
||||||
|
|
||||||
Sometimes it's necessary to have multiple forms display on the same HTML page,
|
Sometimes it's necessary to have multiple forms display on the same HTML page,
|
||||||
|
|
Loading…
Reference in New Issue