Opened 17 years ago

Closed 17 years ago

#5167 closed (invalid)

UnicodeDecodeError in MultiWidget

Reported by: Artyom Gnilov <boobsd@…> Owned by: Adrian Holovaty
Component: Forms Version: dev
Severity: Keywords: unicode
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Code of my ComplexMultiWidget:

class ComplexMultiWidget(MultiWidget):
    def __init__(self, widgets=None, attrs=None):
        if not widgets:
            widgets = (TextInput(), TextInput())
        super(ComplexMultiWidget, self).__init__(widgets, attrs)
    def decompress(self, value):
        if value:
            return value
        return [None for a in range(len(self.widgets))]
    def format_output(self, rendered_widgets):
        return _('to').join(rendered_widgets)

In settings.py:

LANGUAGE_CODE = 'ru-ru'

Traceback:

Traceback (most recent call last):
File "/usr/local/lib/python2.4/site-packages/django/template/__init__.py" in render_node
  754. result = node.render(context)
File "/usr/local/lib/python2.4/site-packages/django/template/defaulttags.py" in render
  228. return self.nodelist_true.render(context)
File "/usr/local/lib/python2.4/site-packages/django/template/__init__.py" in render
  739. return ''.join([force_unicode(b) for b in bits])
File "/usr/local/lib/python2.4/site-packages/django/utils/encoding.py" in force_unicode
  37. s = unicode(s)
File "/usr/local/lib/python2.4/site-packages/django/newforms/forms.py" in __unicode__
  77. return self.as_table()
File "/usr/local/lib/python2.4/site-packages/django/newforms/forms.py" in as_table
  155. 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
  140. output.append(normal_row % {'errors': force_unicode(bf_errors), 'label': force_unicode(label), 'field': unicode(bf), 'help_text': help_text})
File "/usr/local/lib/python2.4/site-packages/django/newforms/forms.py" in __unicode__
  237. return self.as_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/widgets.py" in render
  378. return self.format_output(output)
File "/root/projects/auto/../auto/ad/forms.py" in format_output
  29. return _('to').join(rendered_widgets)

  UnicodeDecodeError at /catalog/search/simple/
  'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)

Change History (1)

comment:1 by boobsd@…, 17 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top