分页中的Django行号 [英] Django Row Number in Pagination

查看:86
本文介绍了分页中的Django行号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以获取Paginator中显示的项目的行号?例如,我设置一个页面应包含50个项目,因此,下一页的行号应从51开始.但是,我找不到任何方法来执行此操作,因此当我使用forloop.counter时,行号会重置每页.

Is there a way in getting the row number for items displayed in Paginator? For example, i set that a page should contain 50 items so, the next page row number should start at 51. However I cannot find any way to do this, and when I use forloop.counter the row number resets every page.

推荐答案

您可以使用 add 模板标记,可将当前计数从分页器添加到forloop

You can use the add template tag to add the current count from the paginator to the forloop

{{ forloop.counter.0|add:paginator.page.start_index }}

这篇关于分页中的Django行号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆