#12645: UnicodeEncodeError when validating forms with non-ascii names
---------------------+------------------------------------------------------
Reporter: alanjds | Owner: nobody
Status: new | Milestone: 1.2
Component: Forms | Version: 1.1
Keywords: unicode | Stage: Unreviewed
Has_patch: 1 |
---------------------+------------------------------------------------------
I am creating forms dynamically, so users can type field names.
Django is raising UnicodeEncodeError when some field name has a non-ascii
name. Is simple not acceptable to constrain users to ASCII only.
Baked example:
{{{
class UtilizacaoForm(forms.Form):
pass
ut = UtilizacaoForm()
ut.fields[u'Diâmetro'] = forms.CharField(max_length=3)
ut.is_valid()
File "django/forms/forms.py" in is_valid
120. return self.is_bound and not bool(self.errors)
File "django/forms/forms.py" in _get_errors
111. self.full_clean()
File "django/forms/forms.py" in full_clean
242. if hasattr(self, 'clean_%s' % name):
Exception Type: UnicodeEncodeError at /novakoski/modelos/detalhe/1/
Exception Value: ('ascii', u'clean_Di\xe2metro', 8, 9, 'ordinal not in
range(128)')
}}}
Occurs because hasattr(obj, str) can't handle non-ascii at str, before
preparing to call clean_fieldname.
Bug found at 1.1.1 (r11612), but stays alive at actual TRUNK (r12264).
Original traceback paste: http://dpaste.com/hold/147583/
Quick fix added.
--
Ticket URL: <http://code.djangoproject.com/ticket/12645>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.