【发布时间】:2021-04-26 16:44:06
【问题描述】:
我有一个关于 django-bootstrap4 (https://django-bootstrap4.readthedocs.io/en/latest/templatetags.html#bootstrap-button) 的 bootstrap_button 模板标签的问题,是否可以在 href 中包含我的标签中的标签,如下所示:
{% bootstrap_button "Supprimer" button_type="link" href="../../delete/{{article.id}} " button_class="btn-danger" %}
但是{{article.id}} 没有被解释,它给了我一个到http://127.0.0.1:8000/delete/{{article.id}} 的链接
我也试过了:
{% bootstrap_button "Supprimer" button_type="link" href="{% url 'delete' article.id %}" button_class="btn-danger" %}
它返回
TemplateSyntaxError at /edit/127/
Could not parse the remainder: '"{%' from '"{%'
Request Method: GET
Request URL: http://127.0.0.1:8000/edit/127/
Django Version: 3.0.5
Exception Type: TemplateSyntaxError
Exception Value:
Could not parse the remainder: '"{%' from '"{%'
但是这些语法都不起作用... 你能帮我让它工作吗?
谢谢
【问题讨论】:
标签: django bootstrap-4 django-templates django-bootstrap4