I want to do the below list iteration in django templates:
foo = ['foo', 'bar'];
moo = ['moo', 'loo'];
for (a, b) in zip(foo, moo):
print a, b
django code:
{% for a, b in zip(foo, moo) %}
{{ a }}
{{ b }}
{% endfor %}
I get the below error when I try this:
File "/base/python_lib/versions/third_party/django-0.96/django/template/defaulttags.py", line 538, in do_for
raise TemplateSyntaxError, "'for' statements should have either four or five words: %s" % token.contents
How do I accomplish this?
It’s possible to do
but you cannot make a call to
zipwithin theforstructure. You’ll have to store the zipped list in another variable first, then iterate over it.