web 开发(5)- HttpRequest对象

image

json

发送数据
image
接收数据
def json(request):
body = request.body
#print(body)
body_str = body.decode()
print(body_str)
print(type(body_str))
import json
body_dict = json.loads(body_str)
print(
body_dict
)
return HttpResponse('json')

请求代码

image

Session

Session 保存到服务器,cookie到本地

类视图的定义

class 类视图名字(View):
def get(self,request):
return HttpResponse('xxx')
def http_method_lower(self,request):
return HttpResponse('xxx')

  1. 继承自View

MRO

image

调用顺序

posted @ 2024-09-11 17:48  温酒待君归  阅读(12)  评论(0)    收藏  举报
levels of contents