Django view function of the three kinds of response mode

 

View function response process:

from django.shortcuts import render,HttpResponse,redirect

 

( . 1 ) the render process template file, the template can be rendered, the first argument must be packaged metadata request data request

return  render(request,"index.html",{"name":"zhang"})

 

( 2 ) the HttpResponse  processing string data, string may be tagged

return HttpRequest("<a href='http://www.baidu.com'>百度</a>")

 

( 3 ) redirect  processing redirect file

return redirect("index0.html")

 

Guess you like

Origin www.cnblogs.com/open-yang/p/11221451.html