【发布时间】:2019-03-12 00:52:26
【问题描述】:
我遵循了类似线程中的说明,例如:How do you index on a jinja template?
但我的 html 模板无法正常工作,因此整个 django 项目没有响应。
我得到的错误:
模板渲染时出错。
无法解析剩余部分:来自“songs_titles[loop.index0]”的“[loop.index0]”
我的代码如下所示:
{% if converted_files_urls %}
<p>Titles: {{ songs_titles }}</p>
{% for n in converted_files_urls %}
<a href="{{ n }}" download>Download: {{ songs_titles[loop.index0] }}</a>
<br/>
{% endfor %}
{% endif %}
并且 {{ song_titles }} 呈现为列表,所以至少到这里它工作正常。 我做错了什么?
【问题讨论】:
-
你没有使用 Jinja。这是 Django 模板语言。
标签: python html django templates jinja2