diff --git a/Django5/urls.py b/Django5/urls.py index 1c49228..8076b69 100644 --- a/Django5/urls.py +++ b/Django5/urls.py @@ -46,6 +46,7 @@ urlpatterns = [ # 媒体路由 re_path('media/(?P.*)', serve, {'document_root': settings.MEDIA_ROOT}, name='media'), + # 路由重定向,用RedirectVIew实现 # 访问http://localhost:8000/redirectTo直接跳转到http://localhost:8000/index/ path('redirectTo',RedirectView.as_view(url="index/")), diff --git a/helloWorld/static/error.html b/helloWorld/static/error.html index fb608ba..7adaedf 100644 --- a/helloWorld/static/error.html +++ b/helloWorld/static/error.html @@ -5,6 +5,7 @@ Title + 系统运行有问题 \ No newline at end of file diff --git a/helloWorld/views.py b/helloWorld/views.py index 819cc6f..9d36457 100644 --- a/helloWorld/views.py +++ b/helloWorld/views.py @@ -9,6 +9,7 @@ def index(request): def blog(request, id): + #输入http://localhost:8000/blog/0会跳转到http://localhost:8000/static/error.html if id==0: return redirect("/static/error.html")