django视图层(jsonrespons)
JsonRespone实现前后端分离
def index(reqest):
res = {'name':'jason',age':'18'}
return HttpResponse(json.dumps(res))
如果内容中有中文
def index(reqest):
res = {'name':'阿三',age':'18'}
return HttpResponse(json.dumps(res,json_dumps_params={“ensure_ascii”:False}))