视图:
request.GET 获取数据
request.POST 提交数据
request.FILES 获取文件用
checkbox 等多选的内容 request.POST.getlist()
上传文件,from要做特殊的设置
obj=request.FIFLES.get('fafa')
obj.name
f=open(obj.name,mode='wb')
for item in obj.chunks():
f.write(item)
f.close()
html文件:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <form action="/cmdb/login/" method="POST" enctype="multipart/form-data"> <p> <input type="text" name="user" placeholder="用户名" /> </p> <p> <input type="password" name="pwd" placeholder="密码" /> </p> <input type="submit" value="提交"/> </form> </body> </html>