在jinja2模板中嵌套for循环

时间:2016-11-16 20:41:24

标签: python templates jinja2

{% for key in data %}
{% if 'assignedUser' in key %}
    {% for key_1, value_2 in data[key].items() %}
    <li>Assigned User: data.values_2()</li>
    {% endfor %}
{% endif %}
{% endfor %}

我试图让jinja模板的行为与此python语句类似:

for key in data:
if key == 'assignedUser':
    for key_1, value_2  in data[key].items():
        print('Assigned User: ' + str(value)) 

&#39;数据&#39;对象:

{
  "assignedUser": {
    "username": "name@email.com"
}, 

0 个答案:

没有答案