在Why is Django blocktrans working one place and not another?中,我问了一个类似的问题,并在“使用i18n”响应解决了相关行为后接受了答案。在这里,我在Pinax 0.9a1的模板中得到一个TemplateSyntaxError,用于查看给定用户的关注者:
{% extends "microblogging/base.html" %}
{% load i18n %}
{% load avatar_tags %}
{% load account_tags %}
{% user_display other_user as other_user_display %}
{% block head_title %}{% blocktrans %}Followers of {{ other_user_display }}{% endblocktrans %}{% endblock %}
错误是:
TemplateSyntaxError at /tweets/followers/ABC/
Caught KeyError while rendering: u'other_user_display'
如果我正确读取模板,模板中倒数第二个(非空白)行定义other_user_display
。 user_display()
中定义了lib/python2.7/site-packages/pinax/apps/account/utils.py
。
要使user_display other_user
/ other_user_display
可用,还需要做些什么?
答案 0 :(得分:1)
在blocktrans标记内定义{{ other_user_display }}
变量。
来自https://docs.djangoproject.com/en/1.9/topics/i18n/translation/#blocktrans-template-tag