render,render_to_redponse,locals,redirect重定向

#=============================================================
#1.render进行页面渲染
star='you are so beautiful'
star2='handsome'
# render_to_response需要引入
# return render_to_response('test.html',{'name1':star,'name2':star2})
#2.locals()
#locals()可以将函数所有的变量传给前端(对效率有一定的影响)
# return render_to_response('test.html',locals())
# return render(req,'test.html',locals())
#3.redirect()---------重定向
# return redirect('http://www.baidu.com')
#NETWORK中对应的状态码:302------重定向
def login(req):
if req.method=="POST":
if 1:
return redirect('http://www.baidu.com')

return render(req, 'land.html')
=============================================================


原文地址:https://www.cnblogs.com/startl/p/12361166.html