How to get an X from a range (1000, 0) in Django Template when you run through a for loop (0, 1000)?

Actually, I run through a regular loop:

{% for post in posts %}
And I need here X = 1000 then 999 then 998. 
{% endfor %}

How to do it? Do you have any ideas? I tried:

{% with x=1000 %}
    {% for post in posts %}            
        {{ x|add:"-1" }}
    {% endfor %}
{% endwith %}

But it doesn't save that x. It shows 999 each time.

I am not sure but you can try it by creating a custom simpletag that takes context object.

Back to Top