Could not parse the remainder: '()' from 'forloop.counter|add:page_obj.start_index()'

I am trying to use a value 'start_index' from paginator's 'get_page()' object. This is required so my for loop can display id of an element according to the amount of previus elements in earlier pages. When i try to add this value to the forloop counter inside a template i get next error: error message

my view:

def openAllOrders(request):
orders = cache_getFilteredOrders(request)
orders_per_page = 10
paginator = Paginator(orders, orders_per_page)
page_number = int(request.GET.get('page', 1))
page_obj = paginator.get_page(page_number)

orders_before = (page_number-1) * orders_per_page
page_orders = page_obj.object_list
tbody_html = getOrdersTable(request, page_orders, orders_before)
context = dict(tbody=tbody_html,
               page_obj=page_obj,
               type=request.GET.get('type'),
               date_start=request.GET.get('date_start'),
               date_end=request.GET.get('date_end'),
               orders_amount=len(orders),)
return render(request, "order.html", context)

page_obj.start_index() value in debugger: enter image description here

what am i doing wrong, and how should i add this value to forloop counter correctly? Thanks in advance!

If the template has invalid syntax, it raises TemplateSyntaxError. Here start_index should be called without parenthesis and I would suggest to use forloop.counter0 over forloop.counter.

  {{ forloop.counter0|add:page_obj.start_index }}  
Back to Top