Opened 12 years ago

Closed 12 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: master
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: UI/UX:


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/" in render_node
  712. result = node.render(context)
File "/store/django/django/template/" in render
  763. return self.encode_output(output)
File "/store/django/django/template/" in encode_output
  745. return str(output)
File "/store/django/django/newforms/" in __str__
  145. return self.as_widget(self._field.widget)
File "/store/django/django/newforms/" in as_widget
  159. return widget.render(self._name,, None), attrs=attrs)
File "/store/django/django/newforms/" 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@…> 12 years ago.
minimal test case

Download all attachments as: .zip

Change History (5)

comment:1 Changed 12 years ago by Adrian Holovaty

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

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

Attachment: tests.diff added

minimal test case

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

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

comment:3 Changed 12 years ago by Sergey <rushman@…>

Cc: sergey.kirillov@… added

comment:4 Changed 12 years ago by Adrian Holovaty

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