mikemaccana
mikemaccana

Reputation: 123238

Django: any use of blocktrans causes TemplateSyntaxError

Using Django 1.2.1, any use of blocktrans breaks my template. Eg

{%blocktrans%}text{%endblocktrans%}

Results in:

Django Version: 1.2.1 Exception Type: TemplateSyntaxError Invalid block tag: 'blocktrans'

Removing the blacktrans causes the code to work. Django s running on GAE if that's relevant.

Upvotes: 8

Views: 1643

Answers (2)

mikemaccana
mikemaccana

Reputation: 123238

Answering my own question, I'd forgotten:

{% load i18n %}

In the top of the template. This is required to use the blocktrans tag.

Edit: See orokusaki's improved answer below to fix this permanently for all your templates.

Upvotes: 19

orokusaki
orokusaki

Reputation: 57128

Just add that to your built-in tags like this, instead:

# in urls.py
template.add_to_builtins('django.templatetags.i18n')

Any tag I'm using in multiple templates, I just load into there.

Upvotes: 5

Related Questions