重定向
生活中的案例
django.shortcuts.redirect 方法
-
重定向新地址
from django.shortcuts import redirect def my_view(request): return redirect('https://www.itbaizhan.com/')
-
通过传递硬编码的URL重定向:
def my_view(request): return redirect('/some/url/')
-
通过传递一个URLConf调度器中配置path或re_path的名称,以及可选的一些位置或关键字参数,该URL将使用reverse()方法反向解析 :
def my_view(request):