From a29a0137a9560c9341c20d4d2231cde63ad0820e Mon Sep 17 00:00:00 2001 From: mxjdi Date: Sun, 27 Apr 2025 22:24:46 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=87=8D=E5=AE=9A=E5=90=91?= =?UTF-8?q?=E5=93=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Django5/settings.py | 2 +- helloWorld/views.py | 7 +++++-- {helloWorld/static => static}/error.html | 0 {helloWorld/static => static}/logo.jpg | Bin static/new.html | 10 ++++++++++ 5 files changed, 16 insertions(+), 3 deletions(-) rename {helloWorld/static => static}/error.html (100%) rename {helloWorld/static => static}/logo.jpg (100%) create mode 100644 static/new.html diff --git a/Django5/settings.py b/Django5/settings.py index 89733c9..534e0fc 100644 --- a/Django5/settings.py +++ b/Django5/settings.py @@ -127,7 +127,7 @@ USE_TZ = True STATIC_URL = 'static/' # 设置静态资源文件集合 -# STATICFILES_DIRS = [BASE_DIR / 'static', BASE_DIR / 'helloworld/images'] +STATICFILES_DIRS = [BASE_DIR / 'static', BASE_DIR / 'helloworld/images'] # 设置媒体路由 MEDIA_URL = '/media/' diff --git a/helloWorld/views.py b/helloWorld/views.py index 9d36457..ed5ec90 100644 --- a/helloWorld/views.py +++ b/helloWorld/views.py @@ -4,8 +4,11 @@ from django.shortcuts import render, redirect # Create your views here. def index(request): - print("页面请求处理中") - return render(request, 'index.html') + # redirect重定向,permanent为True时永久重定向 + return redirect("/static/new.html", permanent=True) + #return redirect("/blog/2") + # print("页面请求处理中") + # return render(request, 'index.html') def blog(request, id): diff --git a/helloWorld/static/error.html b/static/error.html similarity index 100% rename from helloWorld/static/error.html rename to static/error.html diff --git a/helloWorld/static/logo.jpg b/static/logo.jpg similarity index 100% rename from helloWorld/static/logo.jpg rename to static/logo.jpg diff --git a/static/new.html b/static/new.html new file mode 100644 index 0000000..e7cd65b --- /dev/null +++ b/static/new.html @@ -0,0 +1,10 @@ + + + + + Title + + +新页面 + + \ No newline at end of file