开发者

Django template: pass a variable to view {{ dic.{{ a.d }} }}

开发者 https://www.devze.com 2023-02-05 04:24 出处:网络
Django template: pass a variable to view {{ dic.{{ a开发者_高级运维.d }} }} // Access a dictionary

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 %}
0

精彩评论

暂无评论...
验证码 换一张
取 消