Numeric for loop in Django templates

后端 未结 19 1082
温柔的废话
温柔的废话 2020-11-22 03:29

How do I write a numeric for loop in a Django template? I mean something like

for i = 1 to n
19条回答
  •  孤城傲影
    2020-11-22 04:20

    If the number is coming from a model, I found this to be a nice patch to the model:

    def iterableQuantity(self):
        return range(self.quantity)
    

提交回复
热议问题