How can I use a variable as index in django template?
Right now I get this error:
Exception Type:
TemplateSyntaxError
Exception Value:
Could not parse the remainder: '[year]' from 'bikesProfit.[year]'
I also tried {{ bikesProfit.year }} but this gives an empty result.
{% for year in years_list %}
<tr>
<th>Total profit {{ year }}:</th>
</tr>
<tr>
<th></th>
<th> {{ bikesProfit[year] }} </th>
...
{2012:10.0, 2011:13.0}thenbikesProfit.yearshould work. Are you perhaps mixingstrandintkeys for year?bikesProfitandyears_listlook like when you pass them to the context?year, but the actual year (2000).