Django: Nested variables in templates

扶醉桌前 提交于 2019-12-11 01:55:08

问题


In one of my django login templates, I have a line:

<input type="hidden" name="next" value="{{ next|default:'{% url jobseeker_home %}' }}" />

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 %}" />

Unfortunately, the {% url jobseeker_home %} is not being resolved. How can I solve this?

Thanks


回答1:


Variables can be declared within a Django template:

{% url jobseeker_home as home_url %}
<input type="hidden" name="next" value="{{ next|default:home_url }}" />


来源:https://stackoverflow.com/questions/5746473/django-nested-variables-in-templates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!