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

yipeiwu_com5年前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找出完数的方法

如下所示: # -*- coding: utf-8 -*- # 要求:用python方法找出1000以内的所有完数,并输出。 def f(n): list = [] for i...

Python开发的实用计算器完整实例

Python开发的实用计算器完整实例

本文实例讲述了Python开发的实用计算器。分享给大家供大家参考,具体如下: 实现功能:图形界面PyQt,输入框,+,—,*,/ ;乘方 ,开方 ,取余,清零。 1. Python代码:...

python生成特定分布数的实例

我就废话不多说了,直接上代码吧! from scipy.stats import binom, norm, beta, expon import numpy as np import...

Python的多维空数组赋值方法

Python里面的list、tuple默认都是一维的。 创建二维数组或者多维数组也是比较简单。 可以这样: list1 = [1,2,] list1.append([3,4,])...

python 定义给定初值或长度的list方法

python 定义给定初值或长度的list方法

1. 给定初值v,和长度l,定义list s 或者: 2. 产生一个数值递增list 2.1 从0开始以1递增 2.2 在[a,b)区间上以1递增 2.3 在[a,b)区间上以c...