我升级到django1.2,现在收到这个错误消息,它看起来与i18n有关。你能告诉我该怎么做吗?谢谢
global name '_' is not defined
Traceback (most recent call last):
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 515, in __call__
handler.get(*groups)
File "/base/data/home/apps/classifiedsmarket/blobstore.348713784647505124/i18n.py", line 252, in get
loginmsg = loginmsg + '<a href=\"%s\">%s</a>' % ('login',_("Log in"))
NameError: global name '_' is not defined
在添加了新的import语句后更新代码
^{pr2}$在模板中
<ul><li><a href="ai">{% trans "Add" %}</a></li>
<li><a href="li">{{ latest.modified|date:"d M" }}</a></li>
<li>{% if user %}<a href="{{ user_url|fix_ampersands }}">{% trans "Log out" %}</a>
{% else %}{% trans "Log in" %}{{loginmsg}}{% endif %}</li>
</ul>
引导视图上的垃圾,如此处的图像,其中预期的输出是链接和按钮。你能再告诉我一点吗?谢谢
现在检查了HTML,它似乎是用escape编码的。你能看出来吗?
<ul><li><a href="ai">Add</a></li><li><a href="li">03 Mar</a></li>
<li>Log in<a href="google.com">Google</a> <a href="google.com">Yahoo</a> <a href="google.com">MySpace</a> <a href="google.com">AOL</a> <a href="login">Log in</a></li>
</ul>
在Old Django 1.0 manual找到这个(appengine的默认版本是0.98)。在
答案如下:
这就是为什么旧的方法有效,同时在Django 1.2中,您需要指定:
正如Niklas R建议的那样。在
看来你失踪了
但我不知道为什么它在以前的版本中起作用。在
相关问题 更多 >
编程相关推荐