对django中render()与render_to_response()的区别详解

yipeiwu_com6年前Python基础

render()与render_to_response()均是django中用来显示模板页面的,但是在django1.3之后,render()便比render_to_response()更加招人待见!最明显的就是前者会自动使用RequestContext,而后者需要coding进去,

例如:

render(request,'share.html', {'registAdd': registAdd})
render_to_response('share.html',{'registAdd':registAdd},context_instance = RequestContext(request))

以上这篇对django中render()与render_to_response()的区别详解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

解决django后台样式丢失,css资源加载失败的问题

解决django后台样式丢失,css资源加载失败的问题

就像这个图的样子: 解决方法,setting.py中DEBUG选项为True,否则无法映射到静态文件目录 以上这篇解决django后台样式丢失,css资源加载失败的问题就是小编分享给大...

Python模块_PyLibTiff读取tif文件的实例

Usage example (libtiff wrapper) from libtiff import TIFF # to open a tiff file for reading:...

对Python闭包与延迟绑定的方法详解

Python闭包可能会在面试或者是工作中经常碰到,而提到Python的延迟绑定,肯定就离不开闭包的理解,今天总结下 关于闭包的概念以及一个延迟绑定的面试题。 Python闭包 1、什么是...

python对视频画框标记后保存的方法

需要画框取消注释rectangle import cv2 import os,sys,shutil import numpy as np # Open the input mov...

python进程池实现的多进程文件夹copy器完整示例

本文实例讲述了python进程池实现的多进程文件夹copy器。分享给大家供大家参考,具体如下: 应用:文件夹copy器(多进程版) import multiprocessing im...