Opened 18 years ago

Closed 17 years ago

#3008 closed defect (fixed)

[newforms] Newforms don't work with utf8 characters in values or options

Reported by: Nebojša Đorđević <nesh@…> Owned by: Adrian Holovaty
Component: Core (Other) Version: dev
Severity: normal Keywords:
Cc: nesh@…, sergey.kirillov@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently I'm using ChoicesField and when I try to render field in the template with {{ form.field }} I got the following traceback:

Traceback (most recent call last):
File "/store/django/django/template/__init__.py" in render_node
  712. result = node.render(context)
File "/store/django/django/template/__init__.py" in render
  763. return self.encode_output(output)
File "/store/django/django/template/__init__.py" in encode_output
  745. return str(output)
File "/store/django/django/newforms/forms.py" in __str__
  145. return self.as_widget(self._field.widget)
File "/store/django/django/newforms/forms.py" in as_widget
  159. return widget.render(self._name, self._form.data.get(self._name, None), attrs=attrs)
File "/store/django/django/newforms/widgets.py" in render
  85. output.append(u'<option value="%s"%s>%s</option>' % (escape(option_value), selected_html, escape(option_label)))

  UnicodeDecodeError at /admin/nekretnine/add/rs/
  'ascii' codec can't decode byte 0xc4 in position 2: ordinal not in range(128)

Attachments (1)

tests.diff (860 bytes ) - added by Nebojša Đorđević <nesh@…> 18 years ago.
minimal test case

Download all attachments as: .zip

Change History (5)

comment:1 by Adrian Holovaty, 18 years ago

Could you please provide a full test case for reproducing this bug? Best would be a patch against trunk/tests/regressiontests/forms/tests.py

by Nebojša Đorđević <nesh@…>, 18 years ago

Attachment: tests.diff added

minimal test case

comment:2 by Nebojša Đorđević <nesh@…>, 18 years ago

Diff display is mangled because patch contains UTF-8 characters.

comment:3 by Sergey <rushman@…>, 17 years ago

Cc: sergey.kirillov@… added

comment:4 by Adrian Holovaty, 17 years ago

Resolution: fixed
Status: newclosed

(In [4076]) newforms: Fixed #3008 -- Widgets now support strings containing utf-8 characters. Thanks for reporting, Neboj?\197?\161a ?\196?\144or?\196?\145evi?\196?\135

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