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 6945421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:26:03+00:00 2026-05-27T13:26:03+00:00

I nearly got my validation message localized as you can see it works for

  • 0

I nearly got my validation message localized as you can see it works for English and Swedish:

English:

enter image description here

Swedish:

enter image description here

But when I switch to Portuguese I get the following error message:

Traceback (most recent call last):
  File "/media/Lexar/montao/lib/webapp2/webapp2.py", line 545, in dispatch
    return method(*args, **kwargs)
  File "/media/Lexar/montao/montaoproject/main.py", line 1749, in post
    current_user=self.current_user,
  File "/media/Lexar/montao/montaoproject/main.py", line 466, in render_jinja
    self.response.out.write(template.render(data))
  File "/media/Lexar/montao/montaoproject/jinja2/environment.py", line 894, in render
    return self.environment.handle_exception(exc_info, True)
  File "/media/Lexar/montao/montaoproject/templates/insert_jinja.html", line 249, in top-level template code
    <ul class="errors">{% for error in form.name.errors %}<li>{{ error }}</li>{% endfor %}</ul>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128)

I think I’ve had this error message before and I don’t know how to handle it. Could you please help me? Why does this error message appear?

The code for my form class is

class AdForm(Form):
    my_choices = [('1', _('VEHICLES')), ('2', _('Cars')), ('3', _('Bicycles'))]

    name = TextField(_('Name'), [validators.Length(min=4, max=50,
                     message=_(u'Name is required') )])
    title = TextField(_('title'), [validators.Required()])
    text = TextAreaField(_('Text'), widget=TextArea())
    phonenumber = TextField(_('Phone number'))
    phoneview = BooleanField(_('Display phone number on site'))
    price = TextField(_('Price'))
    password = PasswordField(_('Password'))
    email = TextField(_('Email'))
    category = SelectField(choices = my_choices, default = '1')

The translation part in my .po file is

msgid "Name is required"
msgstr "É necessário o nome"

My python file begins like this

#!/usr/bin/python
# -*- coding: utf-8 -*-

And AFAIK I’ve set everything I can to unicode and utf-8.

Thank you for the help

  • 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-05-27T13:26:03+00:00Added an answer on May 27, 2026 at 1:26 pm

    If you want to be able to use unicode characters in your translations, you need to use the ugettext_lazy utility function and not gettext_lazy.
    The main difference, as the function name hints, is that ugettext_lazy is unicode when gettext_lazy is not (which makes it not that useful by the way).

    While you’re at it, you could / should use unicode instead of default strings whenever possible, that is, convert input to unicode ASAP, and encode output as late as possible to the relevant encoding.

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

Sidebar

Related Questions

I've got some code that runs on every (nearly) every admin request but doesn't
I've got a buffer overrun I absolutely can't see to figure out (in C).
I played around with nhibernate validator and got a nearly perfect solution. I can
Description: I've got a project which is nearly finished now, but I've noticed the
I'm trying to get forms working with powershell, and I'm nearly there. I've got
EDIT ive got it almost, having and error message now that it can't find
ok so i've nearly got this. But it seems there is some logic error
We got big table with nearly 100+ millions rows. Can someone help how to
So I have the following code, and It works nearly flawlessly, except for the
I've got a database in production for nearly 3 years, on Sql 2008 (was

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.