- from django.shortcuts import render_to_response
-
from polls.models import Poll
-
-
def index(request):
-
latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
-
return render_to_response('polls/index.html', {'latest_poll_list': latest_poll_list})
The
render_to_response() function takes a template name
as its first argument and a dictionary as its optional second argument. It
returns an object of the given template
rendered with the given context.
阅读(1183) | 评论(0) | 转发(0) |