栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Django-render(),render_to_response()和direct_to_template()之间有什么区别?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Django-render(),render_to_response()和direct_to_template()之间有什么区别?

render(request, template[, dictionary][, context_instance][, content_type][, status][, current_app])

render()
是一个
render_to_response
在1.3中崭新的快捷方式的品牌,该快捷方式将自动使用
RequestContext
,从现在开始我肯定会使用它。

render_to_response(template[, dictionary][, context_instance][, mimetype])¶

render_to_response
是教程等中使用的标准渲染功能。要使用
RequestContext
你必须指定
context_instance=RequestContext(request)

direct_to_template
是我在视图中使用的通用视图(而不是在URL中使用),因为像新
render()
功能一样,它会自动使用
RequestContext
及其所有
context_processor
s。

direct_to_template
应避免使用,因为不建议使用基于函数的通用视图。使用render还是实际使用的类,



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/392693.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号