Django Templating: how to access properties of the first item in a list

后端 未结 4 400
粉色の甜心
粉色の甜心 2020-12-12 20:28

Pretty simple. I have a Python list that I am passing to a Django template.

I can specifically access the first item in this list using

{{ thelist|f         


        
4条回答
  •  孤城傲影
    2020-12-12 20:49

    You can access any item in a list via its index number. In a template this works the same as any other property lookup:

    {{ thelist.0.propertyName }}
    

提交回复
热议问题