Opened 17 years ago

Closed 17 years ago

#4663 closed (worksforme)

UnicodeDecodeError with SelectDateWidget

Reported by: boobsd@… Owned by: Manuel Saelices
Component: Forms Version: dev
Severity: Keywords: SelectDateWidget
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Malcolm Tredinnick)

My form:

class EditProfileForm(forms.Form):
    birthday = forms.DateField(widget=SelectDateWidget(years=range(1968, 1988)), label=_('Birthday'))

If USE_I18N = True in settings, I receive UnicodeDecodeError:

Request Method: GET
Exception Type: UnicodeDecodeError
Exception Value: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)
Exception Location: /usr/local/lib/python2.4/site-packages/django/newforms/widgets.py in render, line 173

Change History (4)

comment:1 by Malcolm Tredinnick, 17 years ago

Description: modified (diff)

(Added wiki formatting to description.)

Without a bit more information, it isn't really possible to debug this. I suspect it's probably one of the problems that has been fixed on the Unicode branch. Please cut-and-paste the full traceback: find the link on the Debug screen that says "cut and paste version" and click it, then paste the results into a comment (remember to wrap them in {{{ and }}} markers to get the wiki formatting right).

Also, which locale is in effect when this error occurs?

comment:2 by boobsd@…, 17 years ago

This error occurs with any locale, except for 'en' (for example: 'ru', 'uk', 'de')

Traceback (most recent call last):
File "/usr/local/lib/python2.4/site-packages/django/template/__init__.py" in render_node
  738. result = node.render(context)
File "/usr/local/lib/python2.4/site-packages/django/template/__init__.py" in render
  793. return self.encode_output(output)
File "/usr/local/lib/python2.4/site-packages/django/template/__init__.py" in encode_output
  772. return str(output)
File "/usr/local/lib/python2.4/site-packages/django/utils/encoding.py" in __str__
  31. return self.__unicode__().encode(settings.DEFAULT_CHARSET)
File "/usr/local/lib/python2.4/site-packages/django/newforms/forms.py" in __unicode__
  76. return self.as_table()
File "/usr/local/lib/python2.4/site-packages/django/newforms/forms.py" in as_table
  154. return self._html_output(u'<tr><th>%(label)s</th><td>%(errors)s%(field)s%(help_text)s</td></tr>', u'<tr><td colspan="2">%s</td></tr>', '</td></tr>', u'<br />%s', False)
File "/usr/local/lib/python2.4/site-packages/django/newforms/forms.py" in _html_output
  139. output.append(normal_row % {'errors': bf_errors, 'label': label, 'field': unicode(bf), 'help_text': help_text})
File "/usr/local/lib/python2.4/site-packages/django/newforms/forms.py" in __unicode__
  238. value = self.as_widget(self.field.widget)
File "/usr/local/lib/python2.4/site-packages/django/newforms/forms.py" in as_widget
  265. return widget.render(self.html_name, data, attrs=attrs)
File "/usr/local/lib/python2.4/site-packages/django/newforms/extras/widgets.py" in render
  43. select_html = Select(choices=month_choices).render(self.month_field % name, month_val)
File "/usr/local/lib/python2.4/site-packages/django/newforms/widgets.py" in render
  174. output.append(u'<option value="%s"%s>%s</option>' % (escape(option_value), selected_html, escape(smart_unicode(option_label))))

  UnicodeDecodeError at /accounts/profile/edit/
  'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)

comment:3 by Manuel Saelices, 17 years ago

Owner: changed from nobody to Manuel Saelices
Status: newassigned

comment:4 by Manuel Saelices, 17 years ago

Resolution: worksforme
Status: assignedclosed

I test this ticket after merging unicode branch. I used this form:

from django import newforms as forms
from django.newforms.extras.widgets import SelectDateWidget

class EditProfileForm(forms.Form):
    birthday = forms.DateField(widget=SelectDateWidget(years=range(1968, 1988)), label=_('Birthday'))

I test this with languages es-es and ru-ru. It works for me.

Note: See TracTickets for help on using tickets.
Back to Top