添加了应用内模板目录,访问模板的顺序是按照配置文件里面的顺序

This commit is contained in:
mxjdi 2025-04-24 23:16:16 +08:00
parent 3deab8068e
commit 84f2eae72d
3 changed files with 12 additions and 2 deletions

View File

@ -53,7 +53,7 @@ ROOT_URLCONF = 'Django5.urls'
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'templates'] 'DIRS': [BASE_DIR / 'templates',BASE_DIR / '/helloWorld/templates']
, ,
'APP_DIRS': True, 'APP_DIRS': True,
'OPTIONS': { 'OPTIONS': {

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
应用内模板
</body>
</html>

View File

@ -3,4 +3,4 @@ from django.shortcuts import render
# Create your views here. # Create your views here.
def index(request): def index(request):
return render(request, 'index.html') return render(request, 'index2.html')