Django templates: Group items in Threes

前端 未结 6 582
感情败类
感情败类 2020-12-05 22:24

I have an odd problem with Django. I have a set of objects that Im looping through in a template as you would normally. However, I need to group the items in threes. The lay

6条回答
  •  孤城傲影
    2020-12-05 22:49

    I definitely vote for creating the structure in your view and passing it on to your template in the correct form.

    If you find yourself struggling with template logic then it's a sign you should be doing more of the work in your view. (this also taught me that quite a bit of my view logic needed to be pushed back into my models...)

提交回复
热议问题