我想这样在 django 模板中编写代码:
for i in range(6):
if i%2==0:
print i, i+1
<table class="pp-choice-careers">
<caption>Parent's Choice for Interest Careers</caption>
<tr><th>Careers</th><th>Why this career</th></tr>
{% for career in resultArr.parent_choice_career %}
<tr class="pp-class">
{% if forloop.counter|mod:2 == 0 %}
<td>{% if career == 'NA' %}Not Available{% else %} . {{career.answer}}{% endif %}</td>
{% else %}
<td>{% if career == 'NA' %}Not Available{% else %}{{career.answer}}{% endif %}</td>
{% endif %}
</tr>
{% endfor %}
</table>
我想从两行中的列表中打印两个值,所以我需要在current+1
部分使用else
索引。