Reference list item by index within Django template?

user456584 picture user456584 · Jan 10, 2011 · Viewed 101.5k times · Source

This may be simple, but I looked around and couldn't find an answer. What's the best way to reference a single item in a list from a Django template?

In other words how do I do the equivalent of {{ data[0] }} within the template language?

Thanks.

Answer

Mike DeSimone picture Mike DeSimone · Jan 10, 2011

It looks like {{ data.0 }}. See Variables and lookups.