Author: mtredinnick
Date: 2008-08-31 06:39:06 -0500 (Sun, 31 Aug 2008)
New Revision: 8761
Modified:
django/trunk/django/forms/forms.py
django/trunk/tests/regressiontests/forms/regressions.py
Log:
Fixed #5216 -- Fixed a case of a string not being a unicode string.
Thanks to Vadim Fint for the test case.
Modified: django/trunk/django/forms/forms.py
===================================================================
--- django/trunk/django/forms/forms.py 2008-08-31 11:11:20 UTC (rev 8760)
+++ django/trunk/django/forms/forms.py 2008-08-31 11:39:06 UTC (rev 8761)
@@ -374,7 +374,7 @@
id_ = widget.attrs.get('id') or self.auto_id
if id_:
attrs = attrs and flatatt(attrs) or ''
- contents = '<label for="%s"%s>%s</label>' %
(widget.id_for_label(id_), attrs, contents)
+ contents = u'<label for="%s"%s>%s</label>' %
(widget.id_for_label(id_), attrs, unicode(contents))
return mark_safe(contents)
def _is_hidden(self):
Modified: django/trunk/tests/regressiontests/forms/regressions.py
===================================================================
--- django/trunk/tests/regressiontests/forms/regressions.py 2008-08-31
11:11:20 UTC (rev 8760)
+++ django/trunk/tests/regressiontests/forms/regressions.py 2008-08-31
11:39:06 UTC (rev 8761)
@@ -34,6 +34,16 @@
u'<p><label for="id_username">Nazwa u\u017cytkownika:</label> <input
id="id_username" type="text" name="username" maxlength="10" /></p>'
>>> deactivate()
+There was some problems with form translations in #5216
+>>> class SomeForm(Form):
+... field_1 = CharField(max_length=10, label=ugettext_lazy('field_1'))
+... field_2 = CharField(max_length=10, label=ugettext_lazy('field_2'),
widget=TextInput(attrs={'id': 'field_2_id'}))
+>>> f = SomeForm()
+>>> print f['field_1'].label_tag()
+<label for="id_field_1">field_1</label>
+>>> print f['field_2'].label_tag()
+<label for="field_2_id">field_2</label>
+
Unicode decoding problems...
>>> GENDERS = ((u'\xc5', u'En tied\xe4'), (u'\xf8', u'Mies'), (u'\xdf',
>>> u'Nainen'))
>>> class SomeForm(Form):
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---