mongodb / flask-pymongo

PyMongo support for Flask applications
BSD 2-Clause "Simplified" License
721 stars 175 forks source link

How can I do a counter when iterating over results? #119

Closed IronBrotherz closed 5 years ago

IronBrotherz commented 5 years ago

I want to output something like:

1 10,000

2 12,000

3 56,000

But I have no idea how to do a counter with my loop. Right now I have

        {% for sale in sales %}
        <p>{{sale.amount}}</p>
        {% endfor %}
zcatk commented 5 years ago

{% for sale in sales %}

{{loop.index}} {{sale.amount}}

{% endfor %}