How to use French accent on django template?

655 views
Skip to first unread message

NMarcu

unread,
Nov 12, 2009, 11:24:41 AM11/12/09
to Django users
Hello all,

How to use French accent on django template? It's very strange. in
one template is working very well, but in other(templatetag) not, I
got this error:

TemplateSyntaxError at /operators/ajax

Caught an exception while rendering: 'ascii' codec can't encode
character u'\xe9' in position 2: ordinal not in range(128)


Do you have any idea what I'm doing wrong?
My template look like this:
{% load i18n %}
<th class="editable_field">
{{ column.caption }}
{% if column.href %}
<a href="{{ column.href }}">Sort</a>
{% endif %}
{% if column.filtered %}
(filtered)
{% endif %}
</th>

{{ column.caption }} -> return a French word.

rebus_

unread,
Nov 12, 2009, 11:30:47 AM11/12/09
to django...@googlegroups.com
2009/11/12 NMarcu <marcu....@gmail.com>:
> --

Is column.caption unicode string?
Also does this happen when you call AJAX view or while rendering?
Perhaps you need to explicitly set encoding of python source files by
putting # -*- coding: utf-8 -*- at the top of the file.

Tom Evans

unread,
Nov 12, 2009, 11:38:38 AM11/12/09
to django...@googlegroups.com
Clearly it isn't unicode - \xe9 is é in latin1/iso 8859-1.

Does this come from the database by any chance? Is the database mysql? If so, is the default charset of the {db,connection,client} set to latin1?

Cheers

Tom

Nicu Marcu

unread,
Nov 13, 2009, 4:54:22 AM11/13/09
to django...@googlegroups.com
Is not coming from database, Db is postgresql, and is set to utf-8, and is accept words with accents.

2009/11/12 Tom Evans <tevans.uk@googlemail.com>

--

You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=.



--
All the best,

Nicolae MARCU

Karen Tracey

unread,
Nov 13, 2009, 8:04:45 AM11/13/09
to django...@googlegroups.com
On Fri, Nov 13, 2009 at 4:54 AM, Nicu Marcu <marcu....@gmail.com> wrote:
Is not coming from database, Db is postgresql, and is set to utf-8, and is accept words with accents.



If you post the traceback that goes with the error someone might be able to help. 

Karen

Andy Mikhailenko

unread,
Nov 14, 2009, 8:56:52 AM11/14/09
to Django users
The problem is not in templates. Probably either a view or a template
tag does something wrong to the caption string. If Django hides the
traceback, try testing each module separately. The simplest way to
evade the "raise wrapped" is to raise an exception right _before_
rendering data prepared by your view. Django will display excellent
traceback and expose locals() from the view. You can also pass the
data directly to template filters or tags to see the traceback.
Reply all
Reply to author
Forward
0 new messages