From 3f1a01d9427921a47b666305f7ba534f999b6ba7 Mon Sep 17 00:00:00 2001 From: mxjdi Date: Sat, 26 Apr 2025 23:18:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=AF=E7=94=B1=E9=87=8D=E5=AE=9A=E5=90=911?= =?UTF-8?q?=E3=80=81=E8=B7=AF=E7=94=B1=E9=87=8D=E5=AE=9A=E5=90=912?= =?UTF-8?q?=E3=80=81=E8=A7=86=E5=9B=BE=E9=87=8D=E5=AE=9A=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Django5/urls.py | 1 + helloWorld/static/error.html | 1 + helloWorld/views.py | 1 + 3 files changed, 3 insertions(+) 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")