Django必会三板斧

HttpResponse ========= 返回字符串类型的数据

render            ==========返回html页面并且支持传值

redirect      =========重定向

 

使用方法:

from django.shortcuts import render,HttpResponse,redirect

def index(request):
"""
:param request: 请求相关的所有数据--对象
:return:
"""
# return HttpResponse('你好啊')
# return render(request, 'myfirst.html') # 自动去templates文件夹下查找文件
return redirect('https://www.baidu.com') # 跳转至对应地址

 

posted @ 2023-10-17 16:58  wellplayed  阅读(5)  评论(0编辑  收藏  举报