HttpResponseRedirect()不常用
redirect(to,permanent=False,*args,**kwargs)
to:指重定向的位置,可以是视图,也可以是url地址,也可以是一个模块...permanent默认值是False,代表是否永久重定向。...(*args,**kwargs在我其它博客中有讲)
book/views.py
from django.http import HttpResponse
from django.shortcuts import...return redirect('loose')
def error(request):
return HttpResponse("你走丢了")
book/urls.py
from django.urls...[
path('', views.index,name='index'),
path('error/', views.error,name='loose'),
]
启动服务器后会自动重定向到