Django必会三板斧

发布时间 2023-10-17 17:03:19作者: wellplayed

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') # 跳转至对应地址