例如,这不起作用:
{% for i in artist_number %}
<li><a href="#{{ forloop.counter0 }}">{{hash_1.items.forloop.counter0.0}}</a></li>
{% endfor %}
但这有效:
{% for i in artist_number %}
<li><a href="#{{ forloop.counter0 }}">{{hash_1.items.0.0}}</a></li>
{% endfor %}
为什么Django只是将forloop.counter0的值放在这里hash_1.items.X.0
这只是一个例子。这是我无法解决的另一个问题:
list = [0,1,2,3,4,5,6,7,8,9,10]
hash_1= {}
#some operations done with these variables.
{% for i in list %}
<li><a href="#{{ forloop.counter0 }}">{{hash_1.items.i.0}}</a></li>
{% endfor %}