template.html
views.py
<!DOCTYPE html>
<html>
<body>
<ul>
{% for x in cars %}
<li>{{ x }}:
<ul>
{% for y in colors %}
<li>
{{ forloop.parentloop.counter }}
{{ y }}
</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
<p>Check out views.py to see what the cars and colors object look like.</p>
</body>
</html>
from django.http import HttpResponse
from django.template import loader
def testing(request):
template = loader.get_template('template.html')
context = {
'cars': ['Ford', 'Volvo', 'BMW'],
'colors': ['Red', 'Green', 'Blue']
}
return HttpResponse(template.render(context, request))