【发布时间】:2021-04-27 23:17:58
【问题描述】:
{% if hosts %}
<div class="row">
{% for host in hosts %}
{% if host.type_of == "Backend" %}
<div class="col-sm-3">{{ host.type_of }}</div>
{{ headers.{{ forloop.counter0 }} }}
{% endif %}
{% endfor %}
</div>
{% endif %}
我将视图中的数组、主机和标题发送到我的模板,我需要获取具有当前索引的标题元素(获取标题[i])
错误提示
Could not parse the remainder: '{{ forloop.counter0' from 'headers.{{ forloop.counter0'
似乎找不到任何与此相关的示例。我怎样才能达到我想要的?
【问题讨论】: