Code

Opened 7 years ago

Closed 7 years ago

#3904 closed (duplicate)

UnicodeDecodeError with RadioSelect and funky characters

Reported by: Ville Säävuori <Ville@…> Owned by: adrian
Component: Forms Version: master
Severity: Keywords: unicode, newforms
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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 (0)

Change History (2)

comment:1 Changed 7 years ago by Ville Säävuori <Ville@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Just noticed that this is possibly a dupe of #3597

comment:2 Changed 7 years ago by Michael Radziej <mir@…>

  • Resolution set to duplicate
  • Status changed from new to closed

duplicate of #3597

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.