Tuesday, March 25, 2008

Django Template Encoding

When using templates, and we need to use character which are not included in the ASCII character set, like the Spanish accentuated characters, Djanfgo must be informed about such a thing in order to properly handle these characters.

To this end, we need add the following at the first or sencond line of code of the Django source code file:

# coding: utf-8

This will allow rendering Spanish characters like te following, without any problem:

á é í ó ú ü ñ Á É Í Ó Ú Ñ

Here is a good place to start and further understand what we have so far explained here:
Defining Python Source Code Encodings

No comments: