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