我已经在我的查询对象上应用了分页器。当我得到大于 15 的记录时,它们会被跳过到 2 页。
这句话对我来说很好。但是我想问如果我想知道我在模板中的记录号怎么办?
例如:如果我得到 22 条记录,我想得到记录号 1,2,3,4,.... 22
这是我的代码:
paginator.Paginator(query_results, 15)
page = int(request.GET.get('page', '1'))
tickets = ticket_paginator.page(page)
我的模板代码:
<th>{% trans "Title" %}</th>
{% for item in items.object_list %}
<th><a href='view/{{ item.id }}'>{{ item.title }}</a></th>
在这里我想得到记录号。
<th> #</th>
<th>{% trans "Title" %}</th>
{% for item in items.object_list %}
<th>counter</th>
<th><a href='view/{{ item.id }}'>{{ item.title }}</a></th>
有人知道吗?帮帮我