我怎样才能让这个 Django 模板呈现?
How can I get this Django template to render?
在 中,我问了一个类似的问题,并在 "use 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
可用?
在 blocktrans 标记中定义您的 {{ other_user_display }}
变量。
https://docs.djangoproject.com/en/1.9/topics/i18n/translation/#blocktrans-template-tag
中的第二个示例
在
{% 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
可用?
在 blocktrans 标记中定义您的 {{ other_user_display }}
变量。
https://docs.djangoproject.com/en/1.9/topics/i18n/translation/#blocktrans-template-tag