How to access a given list element in django templates?
menu.1 should work
if you know the exact index of your list, it could be cleaner and more explicit to do retrieval in your view.
context['menu_target'] = menu[1]
instead of having a list of empty values and accessing them in your template
I have a list of values in my view where I want to store some classes name and pass them to the template. Here is the list in the view: menu = ['','disabled','','',''] and my code for the template <li class="{{ menu|slice:"1:2"|first }}"></li>.
So far this is the only working code I came with, is there a better way to retrieve the element menu[2] from this list? what is the proper way in django to callback the element[n] of a list within the template?