Forloop counter

forloop.counter is a built-in variable in Django that you can use in your templates to keep track of the current iteration number when looping over a collection of items. It starts at 1 and increments by 1 for each iteration.

It is a very simple but powerful tool in Django. Here are just three ideas of how it can be used, but there are many more ways it can come in handy.

Add numbers t a list of items:

Change the colour of every second row:

Assign a separate popup for each entry:




Fossils app code with forloop examples: