gpt4 book ai didi

样式标签中的 Django 模板变量

转载 作者:行者123 更新时间:2023-12-04 01:55:08 25 4
gpt4 key购买 nike

似乎无法在我的 Django 标记中获得可变百分比宽度输出。

            {% with "width: "|add:percent|add:"%" as percent_style %}
<div class="percentile" style={% include percent_style %} />
{% endwith %}

我在这里做错了什么?我得到这个错误

django.template.exceptions.TemplateDoesNotExist: %

最佳答案

您应该简单地使用 {{ percent_style }} 而不是尝试查找名为 percent_style 的模板的 include 标签:

{% with "width: "|add:percent|add:"%" as percent_style %}
<div class="percentile" style="{{ percent_style }}" />
{% endwith %}

关于样式标签中的 Django 模板变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51107724/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com