Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improved newforms to handle wacky characters in Field help_text

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4543 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 7cb7541971b2e080d1288e24e5705d296b11a021 1 parent babc079
Adrian Holovaty adrianholovaty authored
2  django/newforms/fields.py
View
@@ -51,7 +51,7 @@ def __init__(self, required=True, widget=None, label=None, initial=None, help_te
if label is not None:
label = smart_unicode(label)
self.required, self.label, self.initial = required, label, initial
- self.help_text = help_text
+ self.help_text = smart_unicode(help_text or '')
widget = widget or self.widget
if isinstance(widget, type):
widget = widget()
7 tests/regressiontests/forms/tests.py
View
@@ -2698,6 +2698,13 @@
<li>Username: <input type="text" name="username" maxlength="10" /> e.g., user@example.com</li>
<li>Password: <input type="password" name="password" /><input type="hidden" name="next" value="/" /></li>
+Help text can include arbitrary Unicode characters.
+>>> class UserRegistration(Form):
+... username = CharField(max_length=10, help_text='ŠĐĆŽćžšđ')
+>>> p = UserRegistration(auto_id=False)
+>>> p.as_ul()
+u'<li>Username: <input type="text" name="username" maxlength="10" /> \u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111</li>'
+
# Subclassing forms ###########################################################
You can subclass a Form to add fields. The resulting form subclass will have
Please sign in to comment.
Something went wrong with that request. Please try again.