django-HttpResponse,render,redirect

django-HttpResponse,render,redirect,第1张

概述1.导入相应的包 2.HttpResponse(返回字符串给浏览器) 3.render(可以将后台的数据传给前端,三个参数:request,url,context) 3.redirect(跳转到指定的

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所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1214400.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-05
下一篇2022-06-05

发表评论

登录后才能评论

评论列表(0条)

    保存