对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设计】。

相关文章

python多线程同步实例教程

python多线程同步实例教程

前言 进程之间通信与线程同步是一个历久弥新的话题,对编程稍有了解应该都知道,但是细说又说不清。一方面除了工作中可能用的比较少,另一方面就是这些概念牵涉到的东西比较多,而且相对较深。网络编...

python生成不重复随机数和对list乱序的解决方法

andom.sample(list, n)即是从list中随机选取n个不同的元素 # -*- coding: utf-8 -*- import random # 从一个list中...

python使用xlrd模块读取xlsx文件中的ip方法

程序中经常需要使用excel文件,批量读取文件中的数据 python读取excel文件可以使用xlrd模块 pip install xlrd安装模块 示例: #coding=utf8...

详解Python list和numpy array的存储和读取方法

详解Python list和numpy array的存储和读取方法

numpy array存储为.npy 存储: import numpy as np numpy_array = np.array([1,2,3]) np.save('log.npy'...

探究Python中isalnum()方法的使用

 isalnum()方法检查判断字符串是否包含字母数字字符。 语法 以下是isalnum()方法的语法: str.isa1num() 参数  &nbs...