How to access array elements in a Django template? -


i getting array arr passed django template. want access individual elements of array in array e.g. arr[0], arr[1] etc instead of looping through whole array.

is there way in django template?

thank you.

remember dot notation in django template used 4 different notations in python. in template, foo.bar can mean of:

foo[bar]       # dictionary lookup foo.bar        # attribute lookup foo.bar()      # method call foo[bar]       # list-index lookup 

it tries them in order until finds match. foo.3 list index because object isn't dict 3 key, doesn't have attribute named 3, , doesn't have method named 3.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -