Just a quick question: is there a way to remove an item from a list in the Django template language?
I have a situation where I’m iterating through one list, and printing the first item in another list. Once the first item is printed I want to remove it from that list.
See below:
{% for item in list1 %}
{{list2.0}}
#remove list2.0 from list2
{% endfor %}
Thanks in advance.
If your list1 and list2 are indeed lists and not querysets, this seems to work:
Note that
popdoes not return in this case, so you still need {{ list2.0 }} explicitly.