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 <
In views.py:
foo = ['foo', 'bar'] moo = ['moo', 'loo'] zipped_list = zip(foo,moo) return render(request,"template.html",{"context":zipped_list}
In template.html:
{% for f,m in context%} {{f}}{{m}} {% endfor %}
If f is a queryset returned from database then access it by {{f.required_attribute_name}}
f
{{f.required_attribute_name}}