﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
20251	UnicodeEncodeError with DecimalField	anonymous	nobody	"My form:
{{{
class TestForm(forms.Form):
    value = forms.DecimalField()

}}}
When enteing ""1 грн""


{{{
'decimal' codec can't encode characters in position 4-6: invalid decimal Unicode string
}}}


Method '''to_python''' catch only 'DecimalException' but not 'UnicodeEncodeError'.
{{{


C:\Python\lib\site-packages\django\forms\fields.py in to_python
            """"""
            if value in validators.EMPTY_VALUES:
                return None
            if self.localize:
                value = formats.sanitize_separators(value)
            value = smart_text(value).strip()
            try:
                value = Decimal(value)
    ...
            except DecimalException:
                raise ValidationError(self.error_messages['invalid'])

            return value

        def validate(self, value):

            super(DecimalField, self).validate(value)


}}}
"	Bug	closed	Forms	1.5	Normal	invalid		bmispelon@…	Unreviewed	0	0	0	0	0	0
