Opened 18 years ago
Closed 18 years ago
#3266 closed defect (duplicate)
RadioSelect broken -- UnicodeDecodeError
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Forms | Version: | |
Severity: | normal | Keywords: | |
Cc: | Honza.Kral@…, jl@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
test application:
templates/test_form.html:
{{ form }}
views.py:
# -*- coding: utf-8 -*- from django import newforms as forms from django.shortcuts import * class TestForm( forms.Form ): sel_field = forms.ChoiceField( label=Žluťoučký kůň', choices=[ ( u'Žluťoučký', u'úpěl ďábelské ódy' ), ( u'Žluťoučký', u'úpěl ďábelské ódy' ) ], widget=forms.RadioSelect ) def test_view( request ): return render_to_response( "test_form.html", { 'form' : TestForm() } )
urls.py:
from django.conf.urls.defaults import * urlpatterns = patterns('', (r'^test_form/$', 'myTest.views.test_view' ), )
If you change the widget to Select, everything works OK, with the RadioSelect it fails on UnicodeDecode error.
Unfortunately I do not understand UNICODE in python (I am fairly new to the language) so I cannot fix it myself without guessing.
Change History (7)
comment:1 by , 18 years ago
Cc: | added |
---|
comment:2 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:3 by , 18 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
This code still raises UnicodeDecodeError.
Changing
return self.__unicode__().encode(settings.DEFAULT_CHARSET)
to
return self.__unicode__()
in StrAndUnicode fixes this error.
comment:6 by , 18 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:7 by , 18 years ago
Resolution: | → duplicate |
---|---|
Status: | reopened → closed |
Note:
See TracTickets
for help on using tickets.
Same error here!
I came across the UnicodeDecodeError when I tried to fetch data for dynamic choices that contains non-ascii characters.
For now I solved it by encoding the special characters as html entities which is lame. Especially because the same choices work for widget.Select.
Please help
This bug renders widget.RadioSelect pointless for other languages than non-ascii languages and i18n'ed sites.