Chinaunix首页 | 论坛 | 博客
  • 博客访问: 469214
  • 博文数量: 111
  • 博客积分: 2332
  • 博客等级: 大尉
  • 技术积分: 1187
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-29 11:22
文章分类

全部博文(111)

文章存档

2013年(9)

2012年(28)

2011年(17)

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)
阅读(2048) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~