没整理完
昨日回顾:
视图函数: request对象 request.path 请求路径 request.GET GET请求数据 QueryDict {} request.POST POST请求数据 QueryDict {} request.method 请求方式 "GET" "POST" request.is_ajax() 是否是Ajax请求 request.get_full_path() 包含请求数据的路径 return HttpResponse("响应体字符串") render :渲染 render(request,"index.html") render(request,"index.html",{"name":name}) redirect: 重定向 两次请求
render没有第3个参数时,直接读取文件。
有第3个参数时,判断有没有{}语法,然后替换
redirect是服务器向浏览器发送302指令,它是2次请求。
form表单提交时,url变动了。因为它必然会发生一次请求!
当form表单的action属性为空时,单击提交。它会获取当前url作为action的属性,它和当前url没有任何关系。
思考题:
假设访问的是login,login的视图函数代码为:
def login(request): return render(request,'login.html')