0
from django.template import Template, Context
template = Template("""
{% for language in languages %}
THIS IS forloop.parentloop.first +++++++++
{% for tag in revision_tags %}
{% for case in CASES %}
<tr>
{% if forloop.parentloop.first %}<th rowspan="6">{{ language|capfirst }}</th>{% endif %}
{% if forloop.first %}<th rowspan="2">{{ tag }}</th>{% endif %}
<th>{{ case|capfirst }}</th>
</tr>
{% endfor %}
{% endfor %}
{% endfor %}
""")
c = Context({
'languages': ["english", "french"],
'revision_tags': ["d", "s", "p"],
'CASES': ["foo", "bar"],
})
h = template.render(c)
print h
我希望看到每種語言只有一次,但我得到他們兩次。這是django模板re:forloop.parentloop.first中的錯誤還是我誤解?