python - Django use value of template variable as part of another variable name -


i have loop inside template:

{% in 1234|make_list %} 

i obtain inside loop:

{{ form.answer_{{ }} }} 

i aware above line not valid (it raises templatesyntaxerror), know if there way use value of part other variable name.

first, need custom template filter mimic getattr() functionality, see:

then, need add template filter string concatenation:

{% load getattribute %}  {% in 1234|make_list %}         {% "answer_"|add:i answer %}         {{ form|getattribute:answer }}     {% endwith %} {% endfor %} 

Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -