is there a way to loop over two lists simultaneously in django?

前端 未结 6 1224
小鲜肉
小鲜肉 2020-12-01 16:08

I have two list objects of the same length with complementary data i want to render is there a way to render both at the same time ie.

{% for i,j in table,          


        
6条回答
  •  猫巷女王i
    2020-12-01 17:04

    You'll have to do this in the view - use the builtin zip function to make a list of tuples, then iterate over it in the template.

    Template logic is purposely simple, anything even slightly complex should be done in the view.

提交回复
热议问题