1. GET请求
# query请求
def get(self, request):
print(request.GET)
res = [] # 最终返回的结果集合
search_field = request.GET.get('search_field', '')
page_index = request.GET.get('page_index', 1)
page_size = request.GET.get('page_size', 10)
2. POST请求
# Body请求 form-data类型
def post(self, request):
print(request.POST)
data = json.loads(str(request.POST['data']))
3. PUT请求
# Body请求, x-www-form-urlencoded类型
from django.http import QueryDict
def put(self, request):
print(request.body)
put = QueryDict(request.body)
data = put['data']
data = json.loads(str(data).replace("\t", "").replace("\n", ""))
4. DELETE请求
# Body请求, x-www-form-urlencoded类型
from django.http import QueryDict
def delete(self, request):
print(request.body)
delete = QueryDict(request.body)
data = delete['data']
data = json.loads(str(data).replace("\t", "").replace("\n", ""))
标签:请求,GET,request,replace,Django,data,QueryDict
From: https://www.cnblogs.com/jessecheng/p/17624578.html