开发者

Django: Nested variables in templates

开发者 https://www.devze.com 2023-02-28 11:34 出处:网络
In one of my django login templates, I h开发者_运维技巧ave a line: <input type=\"hidden\" name=\"next\" value=\"{{ next|default:\'{% url jobseeker_home %}\' }}\" />

In one of my django login templates, I h开发者_运维技巧ave 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


Variables can be declared within a Django template:

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

精彩评论

暂无评论...
验证码 换一张
取 消