Django Row Number in Pagination

时光毁灭记忆、已成空白 提交于 2020-02-01 08:44:07

问题


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.


回答1:


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 }}


来源:https://stackoverflow.com/questions/9939917/django-row-number-in-pagination

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!