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

查看:32
本文介绍了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天全站免登陆