#13583 closed (invalid)
Invalid localization of error_messages in form fields — at Version 2
| Reported by: | dmitry_nosov | Owned by: | nobody |
|---|---|---|---|
| Component: | Core (Other) | Version: | 1.2 |
| Severity: | Keywords: | error_messages | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
If I use this construction:
forms.IntegerField(min_value=1, max_value=5,
error_messages = {
'max_value': u'Ошибка!',
})
The error message output is
u'u041e\u0448\u0438\u0431\u043a\u0430!'
Instead of
u'Ошибка!'
Change History (2)
comment:1 by , 15 years ago
comment:2 by , 15 years ago
| Description: | modified (diff) |
|---|---|
| Resolution: | → invalid |
| Status: | new → closed |
There is not enough information here to figure out what's going on....the error message output where? In a template, the snippet provided does produce correct output by default (for example if {{ form }} is used in the template for display). I suspect the observed problem is due to some incorrect way of outputting the error information in the template, or, if the "output" being referred to is some debugging information, then a misunderstanding about how Python displays unicode string representations (as phxx notes), not a bug in Django. A better place to ask for help in either case would be django-users.
I cannot confirm this.
The following code generates the expected output:
class A(forms.Form): value = forms.IntegerField(min_value=1, max_value=10, error_messages = { 'max_value': u'Ошибка!', }) print A({'value':'12'}).errors['value'][0]outputs
Your confusion might be resulting of python's behaviour how unicode strings are handled. If you use a character like б in a string it will be converted into its unicode number which is \u0431 in this case.