Django:任何使用blocktrans都会导致TemplateSyntaxError [英] Django: any use of blocktrans causes TemplateSyntaxError

查看:310
本文介绍了Django:任何使用blocktrans都会导致TemplateSyntaxError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Django 1.2.1,任何使用blocktrans都会破坏我的模板。例如

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

{%blocktrans%}text{%endblocktrans%}

结果:

Django版本:1.2.1
异常类型:TemplateSyntaxError
块标签无效:'blocktrans'

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

删除blacktrans会使代码生效。 Django在GAE上运行,如果这是相关的。

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

推荐答案

只需将其添加到您内置的标签中,

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.

这篇关于Django:任何使用blocktrans都会导致TemplateSyntaxError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆