Django

Code

Ticket #3904 (closed: duplicate)

Opened 2 years ago

Last modified 2 years ago

UnicodeDecodeError with RadioSelect and funky characters

Reported by: Ville Säävuori <Ville@Unessa.net> Assigned to: adrian
Milestone: Component: Forms
Version: SVN Keywords: unicode, newforms
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

I have following list of genders:

GENDERS = (
    ('0', u'En tiedä'),
    ('1', u'Mies'),
    ('2', u'Nainen'),
)

And following line in my form:

gender = forms.ChoiceField(choices=GENDERS, widget=forms.RadioSelect(attrs={'class': 'gender'}), label="Sukupuoli")

And i get this error

UnicodeDecodeError
'ascii' codec can't decode byte 0xc3 in position 204: ordinal not in range(128)
.. /django/newforms/forms.py in _html_output, line 129

A temporary fix is to convert the problematic chars to HTML entities like:

GENDERS = (
    ('0', u'En tied&auml;'),
    ('1', u'Mies'),
    ('2', u'Nainen'),
)

Attachments

Change History

04/03/07 11:51:53 changed by Ville Säävuori <Ville@Unessa.net>

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

Just noticed that this is possibly a dupe of #3597

04/04/07 02:24:29 changed by Michael Radziej <mir@noris.de>

  • status changed from new to closed.
  • resolution set to duplicate.

duplicate of #3597


Add/Change #3904 (UnicodeDecodeError with RadioSelect and funky characters)




Change Properties
Action