Chinaunix首页 | 论坛 | 博客
  • 博客访问: 126394
  • 博文数量: 67
  • 博客积分: 1510
  • 博客等级: 上尉
  • 技术积分: 680
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-29 11:22
文章分类

全部博文(67)

文章存档

2011年(10)

2010年(28)

2009年(29)

我的朋友
最近访客

分类: Python/Ruby

2009-09-02 16:40:58

以前一直以为render_to_response的template参数只能是一个模板字符串,今天在发现他可以从多个模板中查找。
render_to_response中template可以是一个list,如:
return render_to_response(["1.html","2.html","3.html"])
它会按照list里面的先后顺序来查找,如果存在对应的模板即停止查找,使用找到的模板。
django如果自定义admin的template好像就是这样找的吧,
render_to_response(["admin/%s/%s/change_form.html" % (app_label,opts.object_name.lower()),
"admin/%s/change_form.html" % app_label,
"admin/change_form.html"], context_instance=context)
阅读(779) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~