开发者

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开发者_StackOverflow block tag: 'blocktrans'

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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜