Code

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#3395 closed (duplicate)

UnicodeError with newforms and non-english error messages

Reported by: Honza Král <Honza.Kral@…> Owned by: adrian
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@…> 7 years ago.
unicode_newforms_errors_new.patch (28.6 KB) - added by Honza Král <Honza.Kral@…> 7 years ago.
this one actually works ;)
decode-before-unicode.patch (540 bytes) - added by Øyvind Saltvik <oyvind.saltvik@…> 7 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@…> 7 years ago.
Oops, this helped me

Download all attachments as: .zip

Change History (7)

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

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

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design 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 7 years ago by Honza Král <Honza.Kral@…>

this one actually works ;)

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

  • Resolution set to duplicate
  • Status changed from new to closed

duplicate of #3344

sorry, didn't find it before...

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

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

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

Oops, this helped me

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

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.