python - Dynamically generate one value in a Django include tag -


i have include tag works fine if hard code values, need generate on fly using {{ foo_counter }}. doing way:

{% include "template.html" foo=var1 pos="var_num_{{foo_counter.next}}" bool="0" %} 

just outputs string without interpreting variable (as expect). i've tried combinations of tag around either template error or same output.

you can use django's inbuilt add filter: https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#add

{% include "template.html" foo=var1 pos="var_num_"|add:foo_counter.next bool="0" %}


Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -