小编jan*_*anb的帖子

如何在django模板中使用变量作为索引?

如何在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)

python arrays django indexing templates

4
推荐指数
1
解决办法
6263
查看次数

标签 统计

arrays ×1

django ×1

indexing ×1

python ×1

templates ×1