최연석*_*최연석 2 django django-templates
我的模板代码是这个
{% for announcement in announcements %}
<tr>
<td>{{ count }}</td>
<td>{{ announcement.title }}</td>
<td>{{ announcement.user.profile.name }}</td>
<td>{{ announcement.modified }}</td>
</tr>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
我想将公告数从n写入1。
我怎样才能做到这一点?
有一个反向计数器称为forloop.revcounter。
{% for announcement in announcements %}
<tr>
<td>{{ forloop.revcounter }}</td>
<td>{{ announcement.title }}</td>
<td>{{ announcement.user.profile.name }}</td>
<td>{{ announcement.modified }}</td>
</tr>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
441 次 |
| 最近记录: |