首页 > 编程语言 > 详细

python学习3-python views.py的返回值

时间:2018-11-29 12:06:08      阅读:183      评论:0      收藏:0      [点我收藏+]

 

2.首先要说明一点是,对于HttpRequest对象来说,是Django自己创建的,但是HttpResponse就必须要我们自己创建。注意每个view方法都必须返回一个HttpResponse对象,HttpResonse对象也是在Django.http里面,这里我们看看之前一直用到的render函数:

 

def render(request, template_name, context=None, context_instance=_context_instance_undefined, content_type=None, status=None, current_app=_current_app_undefined, dirs=_dirs_undefined, dictionary=_dictionary_undefined, using=None):
...........省略............ return HttpResponse(content, content_type, status) # 可以看到最后返回的就是个HttpResponse对象

python学习3-python views.py的返回值

原文:https://www.cnblogs.com/gyadmin/p/10037220.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!