如何在django模板中使用变量作为索引?
现在我收到此错误:
Exception Type:
TemplateSyntaxError
Exception Value:
Could not parse the remainder: '[year]' from 'bikesProfit.[year]'
Run Code Online (Sandbox Code Playgroud)
我也尝试了,{{ bikesProfit.year }}但这给出了一个空洞的结果.
{% for year in years_list %}
<tr>
<th>Total profit {{ year }}:</th>
</tr>
<tr>
<th></th>
<th> {{ bikesProfit[year] }} </th>
...
Run Code Online (Sandbox Code Playgroud)