摘要: 用 json 模块和 HttpResponse 返回生成的 json views.py: from django.shortcuts import render, HttpResponse import json # json 测试 def json_test(request): data = {" 阅读全文
posted @ 2019-07-30 20:30 Sch01aR# 阅读(1878) 评论(0) 推荐(1) 编辑
摘要: request.method: 获取请求的方法,例如 GET、POST 等 views.py: from django.shortcuts import render, HttpResponse # request 对象 def test(request): print(request.method 阅读全文
posted @ 2019-07-30 18:27 Sch01aR# 阅读(1332) 评论(0) 推荐(0) 编辑
摘要: FBV: Function Base View,基于函数的视图 views.py: from django.shortcuts import render, HttpResponse # FBV def upload(request): if request.method == "POST": fi 阅读全文
posted @ 2019-07-30 17:50 Sch01aR# 阅读(219) 评论(0) 推荐(0) 编辑
摘要: upload.html: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>上传页面</title> </head> <body> <form action="/upload/" method="post" e 阅读全文
posted @ 2019-07-30 17:32 Sch01aR# 阅读(340) 评论(0) 推荐(0) 编辑