根據Django文檔Django的模板加載器不能達到應用模板
「你的項目的模板設置介紹Django會如何加載和渲染模板。默認設置文件配置一個DjangoTemplates後端,其APP_DIRS選項設置爲True。按照慣例DjangoTemplates在每個INSTALLED_APPS中查找「templates」子目錄。「
我的夾層settings.py有此配置
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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',
],
},
},
]
我的目錄結構是
project
app_name
templates
app_name
index.html
但模板加載器在
project
app_name
templates
A停止這是我的app_name模板index.html沒有達到。可能是什麼問題?
任何使Django遞歸到'templates'目錄之外的目錄的方法嗎? – JTheboss
閱讀這個[網站](http://stackoverflow.com/questions/1740436/what-is-the-best-location-to-put-templates-in-django-project)也許會有助於回答你的問題,但在您的應用程序目錄中創建一個'templates'目錄是存儲您的應用程序特定模板的理想選擇。 –