Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#13583 closed (invalid)

Invalid localization of error_messages in form fields

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 Karen Tracey)

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 (3)

comment:1 by Gregor Müllegger, 14 years ago

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.

comment:2 by Karen Tracey, 14 years ago

Description: modified (diff)
Resolution: invalid
Status: newclosed

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.

comment:3 by Jacob, 13 years ago

milestone: 1.2

Milestone 1.2 deleted

Note: See TracTickets for help on using tickets.
Back to Top