Chinaunix首页 | 论坛 | 博客
  • 博客访问: 829592
  • 博文数量: 253
  • 博客积分: 6891
  • 博客等级: 准将
  • 技术积分: 2502
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-03 11:01
文章分类

全部博文(253)

文章存档

2016年(4)

2013年(3)

2012年(32)

2011年(184)

2010年(30)

分类: 系统运维

2011-09-19 14:51:44

  1. from django.shortcuts import render_to_response
  2. from polls.models import Poll

  3. def index(request):
  4.     latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
  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.



阅读(1095) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~