Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7868257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:56:42+00:00 2026-06-03T00:56:42+00:00

I am having an issue with rendering Django’s ErrorList if one of my error

  • 0

I am having an issue with rendering Django’s ErrorList if one of my error list items is unicode. When Django renders my errorlist

{{ form.non_field_errors }}

it runs the following code:

class ErrorList(list, StrAndUnicode):
    """
    A collection of errors that knows how to display itself in various formats.
    """
    def __unicode__(self):
        return self.as_ul()

    def as_ul(self):
        if not self: return u''
        return mark_safe(u'<ul class="errorlist">%s</ul>'
                % ''.join([u'<li>%s</li>' % conditional_escape(force_unicode(e)) for e in self])) 

then in force_unicode:

s = unicode(str(s), encoding, errors) 

and then translation in lazy:

def __str_cast(self):
    return str(self.__func(*self.__args, **self.__kw))

The problem is that my string contains ‘å’ symbol and str(u'å') raises UnicodeEncodeError. Is there a good reason why force_unicode and lazy do not use smart_str? I have to do it myself and provide error messages as str objects instead of unicode to make it work.

So I get TemplateSyntaxError Caught UnicodeEncodeError while rendering: ‘ascii’ codec can’t encode character u’\xe5′ in position 17: ordinal not in range(128). This seems telling that rendering my error list item (which is u'å') caused the first UnicodeEncodeError having unicode message ‘ascii’ codec can’t encode character u’\xe5′ and then second UnicodeEncodeError while rendering the message from the first one. Am I mistaken?

Django version: 1.3.1 (but this seems to happen in 1.4 as well)

Full traceback: https://raw.github.com/gist/2499077/ba60cb752acdb429dd6c2814ffb24272037a367a/UnicodeEncodeError.txt

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T00:56:44+00:00Added an answer on June 3, 2026 at 12:56 am

    You can render non_field_errors (and the whole form) manually using insclusion tag or {% include %}. It is not direct solution, but it solves the problem and is more flexible anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having an issue with traversing in jQuery.. hopfully an easy one..but I'm banging my
I'm having an annoying rendering issue with IE my code is CSS : div
This time i'm having an issue with the actual rendering of my model. I
Having an issue rendering jstl tags from within a facelets ui:composition My current xmlns
I'm having an issue with rendering a partial in a modal window. I've tried
I'm relatively new to python/django. I'm having an issue with sending to IDs through
I'm having an issue with IE not rendering a :hover effect. Here is my
Having a strange rendering issue with Safari: I have a table inside a div.
having a slight issue where i am rendering a pdf (stored as a byte
Using Ajax pagination via the will_paginate gem I'm having an issue rendering my collection

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.