码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2018-11-29 12:34:15      阅读:326      评论:0      收藏:0      [点我收藏+]

标签:request   efi   pre   return   undefined   ext   fine   python   turn   

 

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的返回值

标签:request   efi   pre   return   undefined   ext   fine   python   turn   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!