Wes*_*Gun 1 python django django-templates
我在模板中有一个列表用于迭代,并且在进行迭代时,我想在此列表中打印其索引。现在,我正在使用list.index(element),但这是行不通的。
我做:
<tbody>
{% for core in cores %}
<tr>
<td>{{cores.index(core)}}</td> <!-- this line doesn't work -->
<td>{{core.user}}</td> <!-- this line works. -->
Run Code Online (Sandbox Code Playgroud)
这样不是吗?我该怎么办for i in length(cores)?
| 归档时间: |
|
| 查看次数: |
1538 次 |
| 最近记录: |