Every once in a while, I need to repeat some block of html in a
django template a fixed number of times. Ideally, I'd just be able to use python's range function. But, django templates don't allow raw python (probably for the best, once you start coding in your template, its a slippery slope). Anyway, for these simple cases, I finally figured out an easy solution:
{% for i in 123|make_list %}
{{ i }}
{% endfor %}
No comments:
Post a Comment