Django – UnicodeDecodeError using i18n

If you’re using i18n in your django website, you may encounter this issue. It took me two hours to find where the problem came from: you have to use ugettext instead of gettext if your translated strings contains non-ascii characters.

(more…)

Django – Absolute media URIs from templates

Sometimes, you need to build an absolute URI to a media file from your templates:

1
http://example.com/media/sample.jpg

After following this small tutorial, you’ll be able to do this:

1
2
{% load mytemplatetags %}
{{ media_name|absolute_media_url:request }}

(more…)