Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#3395 closed (duplicate)

UnicodeError with newforms and non-english error messages

Reported by: Honza Král <Honza.Kral@…> Owned by: Adrian Holovaty
Component: Forms Version: master
Severity: Keywords: unicode newforms errors
Cc: Honza.Kral@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When I use LANGUAGE_CODE = 'cs' and have some errors in newforms, the template rendering fails because the errors are unicode strings, and the rest of the system fails to handle that correctly (so trying {{ form.field.errors|join:", " }} fails horribly).

I attached a patch that takes care of the problem by encoding all the errors using settings.DEFAULT_CHARSET in ValidationError .

All tests pass

Attachments (4)

unicode_newforms_errors.patch (28.2 KB) - added by Honza Král <Honza.Kral@…> 10 years ago.
unicode_newforms_errors_new.patch (28.6 KB) - added by Honza Král <Honza.Kral@…> 10 years ago.
this one actually works ;)
decode-before-unicode.patch (540 bytes) - added by Øyvind Saltvik <oyvind.saltvik@…> 10 years ago.
This helped me, should this be checked in or is there something i'm missing here?
decode-before-unicode.2.patch (539 bytes) - added by Øyvind Saltvik <oyvind.saltvik@…> 10 years ago.
Oops, this helped me

Download all attachments as: .zip

Change History (7)

Changed 10 years ago by Honza Král <Honza.Kral@…>

comment:1 Changed 10 years ago by Honza Král <Honza.Kral@…>

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedDesign decision needed

Changing triage stage to design decision needed - Do we want this, or is there some cleaner and simpler way how to make newforms' errors work for "funky" characters?

Changed 10 years ago by Honza Král <Honza.Kral@…>

this one actually works ;)

comment:2 Changed 10 years ago by Honza Král <Honza.Kral@…>

Resolution: duplicate
Status: newclosed

duplicate of #3344

sorry, didn't find it before...

Changed 10 years ago by Øyvind Saltvik <oyvind.saltvik@…>

Attachment: decode-before-unicode.patch added

This helped me, should this be checked in or is there something i'm missing here?

Changed 10 years ago by Øyvind Saltvik <oyvind.saltvik@…>

Oops, this helped me

comment:3 Changed 10 years ago by Øyvind Saltvik <oyvind.saltvik@…>

Added patch for "funky" characters, decodes the utf8, then re-encodes as unicode.

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