Niklas Rosencrantz
Niklas Rosencrantz

Reputation: 26652

How can I make this loop with Jinja2?

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

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

TypeError: 'builtin_function_or_method' object is not iterable

Thanks for any advice

Upvotes: 7

Views: 7109

Answers (1)

icktoofay
icktoofay

Reputation: 129001

In Jinja2, functions and methods must be explicitly called.

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

Upvotes: 15

Related Questions