Python Django view 两种return 方法

1.使用render方法

    return render(request,'index.html')  -->>  返回的页面内容是index.html的内容,但是url不变,还是原网页的url,(比如是login页面的返回方法,跳转后的url还是为login)   一刷新就返回去了


2.使用redirect方法

    return redirect(request,'idnex.html')  -->> 直接跳转到index.html页面中,url为跳转后的页面url

猜你喜欢

转载自blog.csdn.net/qq_41823953/article/details/79902301
今日推荐