[Fixed]-Forloop counter with dynamic value range

1👍

Well, you can solve it like this:

  1. Install mathfilters:
    pip install django-mathfilters
  2. Add ‘mathfilters’ to Installed_Apps
  3. Replace {{ forloop.counetr }} by something like this in your template:

{{ page_obj.number|add:-1|mul:page_obj.paginator.per_page|add:forloop.counter }}

where:

page_obj.number – page number

page_obj.paginator.per_page – number of items on page

👤Oleg

Leave a comment