我的代码在视图中:
tracks = client.get('/tracks', order='hotness', limit=4)
artwork_url=[]
for track in tracks:
artwork_url.append(str(track.artwork_url).replace("large", "t300x300"))
val={"tracks":tracks,"artwork_url":artwork_url}
return render_to_response('music/tracks.html',val)
在 .html 中
{% for track in tracks %}
<li>
<div class="genre-image">
<img src="{{ artwork_url[forloop.counter] }}">
</div>
{% endfor %}
错误:
Exception Type: TemplateSyntaxError
Exception Value: Could not parse the remainder: '[forloop.counter]' from 'artwork_url[forloop.counter]'