Django template: pass a variable to view {{ dic.{{ a.d }} }}
Django template: pass a variable to view {{ dic.{{ a开发者_高级运维.d }} }}
// Access a dictionary
I need to pass a variable to dic, and this variable come from {{ a.d }}
So, what is the best way to do that?
Ok, I need to look up a dictionary.
{{ a.d }} returns a key.
so {{ dic.key }} will work.
{% with a.d as key %}
...
{{ dic.key }}
...
{% endwith %}
精彩评论