Python Django使用应用程序目录中的html模板
我使用django 1.10.3 我想从应用程序目录使用html模板 我使用文件夹模板和testPage.html创建应用程序测试页面 In view.pyPython Django使用应用程序目录中的html模板,python,django,Python,Django,我使用django 1.10.3 我想从应用程序目录使用html模板 我使用文件夹模板和testPage.html创建应用程序测试页面 In view.py from django.shortcuts import render def page(request): return render(request, 'test_page/testPage.html', locals()) 在settings.py中 TEMPLATES = [ { 'BACKEND': 'dja
from django.shortcuts import render
def page(request):
return render(request, 'test_page/testPage.html', locals())
在settings.py中
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')]
,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
但它不起作用。
如何从目录应用程序使用html模板?目录结构:
project/
test_page/
templates/
test_page/
test_page.html
当您的项目名称为
django_server
且应用程序名称为myapp
(使用python manage.py startapp myapp
生成)时,结构应为:
django_server/
myapp/
templates/
test_page/
testPage.html
你们的问题是?我如何使用dir应用程序中的html模板?它不起作用。错误模板\\”和io.open(origin.name,encoding=self.engine.file\u字符集)作为fp:对不起,格式错误,我现在更新了,您现在可以试试吗?它不起作用。错误模板\\”和io.open(origin.name,encoding=self.engine.file\u字符集)作为fp: