Is it possible with django template tags to skip the first element in a list when doing the for loop? For example I want to begin from element 1 instead from 0.
You can use the continue statement if you need to skip the current iteration of a for or while loop and move onto the next iteration. In this example, we are looping through a string of my name.
You can use a continue statement in Python to skip over part of a loop when a condition is met. Then, the rest of a loop will continue running. You use continue statements within loops, usually after an if statement.
builtin slice filter
{{ qs|slice:"1:" }}
You can e.g. do:
{% if not forloop.first %}
...
{% endif %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With