如何使用Jinja2进行此循环?

如何使用Jinja2进行此循环?

问题描述:

使用Jinja2,我该如何进行迭代,例如与django而不是Jinja一起使用的跟随:

With Jinja2, how can I make an iteration like the folllowing which works with django and not Jinja:

{% for key,value in location_map_india.items %}
{{value.name}}
{% endfor %}

以上是有效的django,但对于Jinja2,它会返回错误消息

The above is valid django but with Jinja2 it returns an error message

TypeError:"builtin_function_or_method"对象不可迭代

TypeError: 'builtin_function_or_method' object is not iterable

谢谢您的建议

在Jinja2中,函数和方法

In Jinja2, functions and methods must be explicitly called.

{% for key,value in location_map_india.items() %}
{{value.name}}
{% endfor %}