
1.导入相应的包
from django.shortcuts import httpResponse,render,redirect
2.httpResponse(返回字符串给浏览器)
def index(request): # 业务逻辑代码 return httpResponse("OK")
3.render(可以将后台的数据传给前端,三个参数:request,url,context)
业务逻辑代码 context={'username':xiximayou',} return render(request,index.HTML",context=context)
3.redirect(跳转到指定的url)
return redirect(www.baIDu.com")
主要还是使用render。
总结以上是内存溢出为你收集整理的django-HttpResponse,render,redirect全部内容,希望文章能够帮你解决django-HttpResponse,render,redirect所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)