Ratan Kumar
Ratan Kumar

Reputation: 1650

google app engine python for loop counter

How to keep count of for loop in google app engine. Like in Django {forloop.counter}, I have used this

  {% for user in users %}
     {{forloop.counter}}
  {%endfor%}

but this giver error as :

UndefinedError: 'forloop' is undefined

Need help with Syntax/App Engine

Library:

 libraries:
 - name: jinja2
 version: latest

Upvotes: 1

Views: 444

Answers (1)

Wooble
Wooble

Reputation: 89897

In Jinja2 templates, you can access a loop counter with:

{{loop.index}}

(which is 1-indexed like Django's forloop.counter; for 0-indexed use loop.index0)

Upvotes: 4

Related Questions