【发布时间】:2019-08-01 08:22:56
【问题描述】:
当我使用任何数字时,我会收到此错误,我也在此站点上看到了一些解决方案,但我无法解决或者我以错误的方式进行操作。 帮助将不胜感激。谢谢
resend_lst的样本数据:['0', '1', '0', '0']
django.template.exceptions.TemplateSyntaxError: 无法解析余数:'[0]' from 'resend_lst[0]'
{% for attendee_data in attendees_data %}
<tr>
<td>{{ attendee_data.attendee.name }}</td>
<td>{{ attendee_data.attendee.email }}</td>
<td>{{ attendee_data.attendee.mobile }}</td>
<td>{{ attendee_data.attendee_response.date }}</td>
</tr>
**resend_lst is a list data type and I need to access this with its index in that loop **
{% if resend_lst[{{forloop.counter}}] == '0' %}
<style>
#response-{{forloop.counter}}{
display:none;
}
#cancel-{{forloop.counter}}{
display:none;
}
#loader-next-{{forloop.counter}}{
display:none;
}
#ajax-loader{
text-align: center;
width:19px;
height:19px;
}
</style>
{% else %}
<style>
#loader-next-{{forloop.counter}}{
display:none;
}
#ajax-loader{
text-align: center;
width:19px;
height:19px;
}
</style>
{% endif %}
<-- some task -->
{% endfor %}
【问题讨论】:
-
如果 jinja2 在 django 中,你能分享你的设置以确保它是正确的吗?
标签: python django django-templates jinja2