How to access element of a list by index in django html template?
Answers
Answered by
2
Let's say you wrote data.obj django tries data.obj and data.obj(). If they don't work it tries data["obj"]. In your case data[0] can be written as {{ data.0 }}. But I recommend you to pull data[0] in the view and send it as separate variable.
Answered by
0
let the name of the list be x.
then,
x.index(0) will show the first element of the list
x.index("0") will show the element with value of "0"
Similar questions