Django access the length of a list within a template

后端 未结 4 814
日久生厌
日久生厌 2020-12-28 11:49

Simple question. I have a list in my template and want to output the length of the list. Do I have to calculate this in my view and hand it over via my context?



        
4条回答
  •  遥遥无期
    2020-12-28 12:03

    Use list|length. | indicates that you will use a filter. The size of the list is

    {{ list|length }}
    

提交回复
热议问题