设置重定向响应
This commit is contained in:
parent
1fbd7cd401
commit
a29a0137a9
@ -127,7 +127,7 @@ USE_TZ = True
|
|||||||
STATIC_URL = 'static/'
|
STATIC_URL = 'static/'
|
||||||
|
|
||||||
# 设置静态资源文件集合
|
# 设置静态资源文件集合
|
||||||
# STATICFILES_DIRS = [BASE_DIR / 'static', BASE_DIR / 'helloworld/images']
|
STATICFILES_DIRS = [BASE_DIR / 'static', BASE_DIR / 'helloworld/images']
|
||||||
|
|
||||||
# 设置媒体路由
|
# 设置媒体路由
|
||||||
MEDIA_URL = '/media/'
|
MEDIA_URL = '/media/'
|
||||||
|
|||||||
@ -4,8 +4,11 @@ from django.shortcuts import render, redirect
|
|||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
def index(request):
|
def index(request):
|
||||||
print("页面请求处理中")
|
# redirect重定向,permanent为True时永久重定向
|
||||||
return render(request, 'index.html')
|
return redirect("/static/new.html", permanent=True)
|
||||||
|
#return redirect("/blog/2")
|
||||||
|
# print("页面请求处理中")
|
||||||
|
# return render(request, 'index.html')
|
||||||
|
|
||||||
|
|
||||||
def blog(request, id):
|
def blog(request, id):
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 170 KiB After Width: | Height: | Size: 170 KiB |
10
static/new.html
Normal file
10
static/new.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Title</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
新页面
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Reference in New Issue
Block a user