2
我在模板文件中有一个“创建新对象”按钮。在Django模板中包含url变量
我想包括按钮在我的网站上的几个地方,但我想包括一个链接模板。
我已经试过
{% include "snippets/icon_add.html" with link="/create_new_item/" only %}
,但我想从{% url 'create_new_item' %}
使用效益。
我可以这样做
{% include "snippets/icon_add.html" with link={% url 'create_new_item' %} only %}
用'{%url'create_new_item'作为the_url%}'不会抛出错误如果URL不存在。 –