-2

this is my home.html

{% for i in ind %}
{{ i.state }}<br>
{% endfor %}

in this for loop i do not want first data coming from ind, i want all data except first data then how to iterate this for loop, this is Django project

this is my views.py

res = requests.get("https://api.covid19india.org/data.json")
ind = res.json()['statewise']

the data of ind variable is going to for loop but i do not want first data of ind variable

1

1 Answer 1

2

You can do:

{% for i in ind %}
    {% if not forloop.first %}  
        {{ i.state }}<br>
    {% endif %}
{% endfor %}

ind will be looped through, but {{ i.state }} will be printed for the first element.

Or, as you can see from the comment section. It is the other way.

{% for i in ind|slice:"1:" %}
    {{ i.state }}<br>
{% endfor %}

Here is the docs for counter concept ind django.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.