小白必会三板斧
HttpResponse
class HttpResponse:
pass
render
def render(...):
return HttpResponse(...)
redirect
def redirect(...)
return redirect_class(...)
JsonResponse
"""
前后端不分离
django写项目(前端直接使用模板层及模板语法)
前后端分离
django写项目(前端使用其他框架和语言)
不同编程语言之间如何交互???
json格式数据
python中如何序列化反序列化
dumps()
loads()
js中如何序列化反序列化
JSON.stringfy()
JSON.parse()
"""
import json
from django.http import JsonResponse
def index(request):
d = {
'username': 'jason老师', 'pwd': 123, 'hobby': [111, 222, 333]}
l = [111,222,333,444,555]
return JsonResponse(l,safe=False)
form表单提交文件