【发布时间】:2016-05-16 17:29:33
【问题描述】:
我是 Django 新手。我将 Django 1.8.6 与 Python 2.7 一起使用。我正在尝试使用一个 base.html 模板,该模板可以在整个站点中全局使用,每个应用程序都可以在其中访问它。这是我的测试站点的当前结构:
twms
民意调查
迁移
静态
模板
项目
迁移
静态
模板
项目
index.html
tmws
静态
模板
tmws
base.html
这里是 project/templates/project/index.html 的代码
{% extends 'tmws/base.html' %}
{% block content %}
<h1>Projects</h1>
<ul>
{% for project in project_list %}
<li><a href="{% url 'project:detail' project.id %}">{{ project.name }}</a></li>
{% endfor %}
</ul>
end of list
{% endblock %}
这是我收到的错误:
TemplateDoesNotExist at /project/
tmws/base.html
如何从我的任何应用访问 tmws/tmws/templates/tmws/base.html?
任何帮助将不胜感激!
如果需要任何其他信息,请告诉我。
编辑
这是我在 settings.py 中的模板设置:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'templates'), # If i leave both or just comment one one out I still get the same error
'tmws.tmws.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',
],
},
},
]
【问题讨论】:
-
您的模板设置中有什么?