Django

Code

Ticket #3395 (closed: duplicate)

Opened 2 years ago

Last modified 2 years ago

UnicodeError with newforms and non-english error messages

Reported by: Honza Král <Honza.Kral@gmail.com> Assigned to: adrian
Milestone: Component: Forms
Version: SVN Keywords: unicode newforms errors
Cc: Honza.Kral@gmail.com Triage Stage: Design decision needed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

unicode_newforms_errors.patch (28.2 kB) - added by Honza Král <Honza.Kral@gmail.com> on 01/29/07 14:51:25.
unicode_newforms_errors_new.patch (28.6 kB) - added by Honza Král <Honza.Kral@gmail.com> on 01/29/07 15:01:19.
this one actually works ;)
decode-before-unicode.patch (0.5 kB) - added by Øyvind Saltvik <oyvind.saltvik@gmail.com> on 02/22/07 13:41:52.
This helped me, should this be checked in or is there something i'm missing here?
decode-before-unicode.2.patch (0.5 kB) - added by Øyvind Saltvik <oyvind.saltvik@gmail.com> on 02/22/07 13:44:07.
Oops, this helped me

Change History

01/29/07 14:51:25 changed by Honza Král <Honza.Kral@gmail.com>

  • attachment unicode_newforms_errors.patch added.

01/29/07 14:53:29 changed by Honza Král <Honza.Kral@gmail.com>

  • needs_better_patch changed.
  • stage changed from Unreviewed to Design decision needed.
  • needs_tests changed.
  • needs_docs changed.

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?

01/29/07 15:01:19 changed by Honza Král <Honza.Kral@gmail.com>

  • attachment unicode_newforms_errors_new.patch added.

this one actually works ;)

01/31/07 09:17:15 changed by Honza Král <Honza.Kral@gmail.com>

  • status changed from new to closed.
  • resolution set to duplicate.

duplicate of #3344

sorry, didn't find it before...

02/22/07 13:41:52 changed by Øyvind Saltvik <oyvind.saltvik@gmail.com>

  • attachment decode-before-unicode.patch added.

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

02/22/07 13:44:07 changed by Øyvind Saltvik <oyvind.saltvik@gmail.com>

  • attachment decode-before-unicode.2.patch added.

Oops, this helped me

02/22/07 13:48:42 changed by Øyvind Saltvik <oyvind.saltvik@gmail.com>

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


Add/Change #3395 (UnicodeError with newforms and non-english error messages)




Change Properties
Action