Code

Opened 7 years ago

Closed 7 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
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:

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@…> 7 years ago.
minimal test case

Download all attachments as: .zip

Change History (5)

comment:1 Changed 7 years ago by adrian

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

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

minimal test case

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

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

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

  • Cc sergey.kirillov@… added

comment:4 Changed 7 years ago by adrian

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

(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

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.