I have a list of 2 dicts
foobar = [ {dict1},
{dict2}
]
Django's docs say that the slice template tag works EXACTLY like python slice.
So I tested in a python shell, and sure enough:
>>> foo = [1,2]
>>> foo[-2]
1
However, when I do this in my template:
{% with foobar|slice:"-2" as previous_thing %}
{{ previous_thing }}
I get an empty list []
.
{% with foobar|slice:"1" as previous_thing %}
yields what I expect (the first item in the list), as does {{ foobar }}
(a list of 2 dicts).
What the heck is going on?!