Jam*_*een 6 python django django-templates django-template-filters
我在模板文件中有一个"创建新对象"按钮.
我想在我的网站上包含几个位置的按钮,但我希望包含带有链接的模板.
我试过了
{% include "snippets/icon_add.html" with link="/create_new_item/" only %}
Run Code Online (Sandbox Code Playgroud)
但我想利用它的好处{% url 'create_new_item' %}.
我能做点什么吗
{% include "snippets/icon_add.html" with link={% url 'create_new_item' %} only %}
Run Code Online (Sandbox Code Playgroud)
Jos*_*mit 12
尝试使用{% url ... as var %}语法.例:
{% url 'create_new_item' as the_url %}
{% include "snippets/icon_add.html" with link=the_url %}
Run Code Online (Sandbox Code Playgroud)
文档链接在这里.
| 归档时间: |
|
| 查看次数: |
2165 次 |
| 最近记录: |