【转】django 三件套(render,redirect,HttpResponse)

时间:2019-10-01 17:48:20   收藏:0   阅读:98

Django基础必备三件套**:

from django.shortcuts import HttpResponse
def index(request):
    # 业务逻辑代码
    return HttpResponse("OK")
from django.shortcuts import render
def index(request):
    # 业务逻辑代码
    return render(request, "index.html", {"name": "alex", "hobby": ["烫头", "泡吧"]})
from django.shortcuts import redirect
def index(request):
    # 业务逻辑代码
    return redirect("/home/")

 

原文:https://www.cnblogs.com/HYanqing/p/11615592.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!