Django:模板中的嵌套变量 [英] Django: Nested variables in templates
本文介绍了Django:模板中的嵌套变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的django登录模板中,有一行:
In one of my django login templates, I have a line:
< input type = hidden name = next value = {{next | default:'{%url jobseeker_home%}'}} />
当我查看生成的HTML页面的源代码,对于上述模板行,我得到以下信息:
And when I view the source code of the HTML page generated, I get the following for the above template line:
< input type = hidden name = next value = {=%url jobseeker_home%} />
不幸的是, {%url jobseeker_home%} 尚未解决。我该怎么解决?
Unfortunately, the {% url jobseeker_home %} is not being resolved. How can I solve this?
谢谢
推荐答案
变量可以是在Django模板中声明:
Variables can be declared within a Django template:
{% url jobseeker_home as home_url %}
<input type="hidden" name="next" value="{{ next|default:home_url }}" />
这篇关于Django:模板中的嵌套变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文