I am trying to figure out the best way to loop a given number of times within a Django template from an integer field
For example, if I have a model:
models.py
class Rating(models.Model):
checked = models.IntegerField(default='0')
unchecked = models.IntegerField(default='0')
And I have a record where checked = 5
, in the template how can I do the following:
{% for i in checked %}
<div>some repeatable content here </div>
{% endfor %}
Since checked
is an integer, it is a non-iterable and it cannot be used in the for-loop. Is there a more simple solution?