TemplateDoesNotExist
提出,但事后证明它找到了一个模板:
Template-loader postmortem
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
Using loader django.template.loaders.app_directories.Loader:
/blah-blah/venv2.7/local/lib/python2.7/site-packages/django/contrib/admin/templates/shopify_app/login.html (File does not exist)
/blah-blah/venv2.7/local/lib/python2.7/site-packages/django/contrib/auth/templates/shopify_app/login.html (File does not exist)
/blah-blah/venv2.7/local/lib/python2.7/site-packages/tinymce/templates/shopify_app/login.html (File does not exist)
/blah-blah/venv2.7/local/lib/python2.7/site-packages/django_tables2/templates/shopify_app/login.html (File does not exist)
/blah-blah/venv2.7/local/lib/python2.7/site-packages/crispy_forms/templates/shopify_app/login.html (File does not exist)
/blah-blah/ppmsys/shopify_app/templates/shopify_app/login.html (File exists)
/blah-blah/ppmsys/campaigns/templates/shopify_app/login.html (File does not exist)
/blah-blah/venv2.7/local/lib/python2.7/site-packages/django_extensions/templates/shopify_app/login.html (File does not exist)
该文件是可读的。
» ls -l ppmsys/shopify_app/templates/shopify_app/login.html
-rw-rw-r-- 1 user1 user1 749 Nov 6 11:55 ppmsys/shopify_app/templates/shopify_app/login.html
为什么TemplateDoesNotExist
被提出?关于下一步该尝试的任何想法?
这是我设置的相关部分:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.webdesign', # for {% lorem %}
# Added by me
'storages',
'phonenumber_field', # for PhoneNumberField
'tinymce', # from django-tinymce, for HTMLField
'django_tables2', # from django-tables2
'crispy_forms', # from django-crispy-forms
'shopify_app', # taken from https://github.com/Shopify/shopify_django_app
# My applications
'mockups',
'campaigns',
]
...
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
],
'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',
'django.core.context_processors.request',
],
'loaders': [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
]
},
},
]
答案 0 :(得分:3)
好的,我找到了。这是愚蠢的,但我会留在这里供其他人参考。
模板来自我正在重用的应用程序。我见过它:
{% extends "base.html" %}
{% block content %}
...
{% endblock %}
并且base.html
在任何地方都不存在。
精细。我没有基本模板,我应该受到惩罚。但不是TemplateDoesNotExist
带有误导性的调试信息。
具体说明shopify_app/login.html
不存在,但不存在的是base.html
。这是误导imho。我花了一个小时调整我的设置让django找到我知道的那个模板!
答案 1 :(得分:0)
from os.path import join, normpath
然后
'DIRS': [
normpath(join(BASE_DIR, 'templates')),
],
'APP_DIRS': True,