1
You’re attempting to treat Django’s template language as if it’s an eval
, and your variable {{product.quantity}}
will be replaced with an integer, resulting in your statement for a in range(x)
being executed.
That’s incorrect.
Django’s template language is not Python. It is written in Python, and it’s syntax resembles Python, but is not Python. You cannot use Python within it.
Django’s template language does not have a native range
template tag.
See this question for an example of how to approach this.
Source:stackexchange.com