#3597: UnicodeDecode error when ChoiceField(w=RadioSelect) has Unicode choices
--------------------------------------------------+-------------------------
Reporter: Georgi Stanojevski <glisha gmail com> | Owner: adrian
Status: new | Component:
django.newforms
Version: SVN | Keywords:
UnicodeDecodeError RadioSelect
Stage: Unreviewed | Has_patch: 1
--------------------------------------------------+-------------------------
When I have a form like this, note the choices with unicode data I get an
UnicodeDecodeError.
I attached a patch which just replaces the __str__ method with __unicode__
for RadioSelect widgets in django/newforms/forms.py +232.
It seems to work.
{{{
#!python
class aform(forms.Form):
def __init__(self, *args, **kwargs):
super(aform, self).__init__(*args, **kwargs)
self.fields['aradio'].choices = [('1',u'јуникод'),('2','latin')]
aradio = forms.ChoiceField(choices=(), widget=RadioSelect())
f = aform()
f.as_ul()
}}}
I get an UnicodeDecodeError.
{{{
#!python
exceptions.UnicodeDecodeError Traceback (most
recent call last)
/home/webstrana/django/kajmakot/<ipython console>
/home/webstrana/django/django_src/django/newforms/forms.py in as_ul(self)
146 def as_ul(self):
147 "Returns this form rendered as HTML <li>s -- excluding the
<ul></ul>."
--> 148 return self._html_output(u'<li>%(errors)s%(label)s
%(field)s%(help_text)s</li>', u'<li>%s</li>', '</li>', u' %s', False)
149
150 def as_p(self):
/home/webstrana/django/django_src/django/newforms/forms.py in
_html_output(self, normal_row, error_row, row_ender, help_text_html,
errors_on_separate_row)
127 else:
128 help_text = u''
--> 129 output.append(normal_row % {'errors': bf_errors,
'label': label, 'field': unicode(bf), 'help_text': help_text})
130 if top_errors:
131 output.insert(0, error_row % top_errors)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 80:
ordinal not in range(128)
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/3597>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---