I am trying pass to list from a view to template in Django.
In my file wiew.py I define the view named hour
# This Python file uses the following encoding: utf-8from django.shortcuts import render
from django.http import HttpResponse
from datetime import datetime
from django.shortcuts import render_to_response# Create your views here.
def hour(request):
now = datetime.now()
list = ['Bern','Bob','Eufronio','Epifanio','El pug']
return render_to_response('hour.html',list)
I'm using shorcuts in my view.
I have a template named hour.html so this way:
<!DOCTYPE html>
<html lang="en">
<head><meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8"><title>Date</title></head>
<body>The names are:{%for item in list%}<li>{{item}}</li>{% endfor %}
</body>
</html>
But my template hour.html is showed empty in the browser. How to can I send the list from my view to template. Thanks for tour attention