2017-10-21 198 views
0

服务器工作正常,但是在使用延长这个“home.html的”文件无法链接模板:'TemplateDoesNotExist在/'错误在Django?

在“home.html做为”:

{%伸出“/模板1 /个人/了header.html”%} 尽管装载本地主机: Django的尝试加载这些模板,按以下顺序:

`使用Django的引擎:

  1. django.template.loaders.app_directories.Loader:在/ usr /local/lib/python2.7/dist-packages/django/contrib/admin/templates/ffgg/home.html(来源不存在)。
  2. django.template.loaders.app_directories.Loader:/usr/local/lib/python2.7/dist-packages/django/contrib/auth/templates/ffgg/home.html(来源不存在)`
+2

的可能的复制[Django的TemplateDoesNotExist?](https://stackoverflow.com/questions/1926049/django-templatedoesnotexist) – thatrockbottomprogrammer

+0

请张贴TEMPLATE_DIRS变量的内容在你的settings.py – rollinger

+0

不要使用绝对路径(除非您的模板真的在该目录中,从根开始)。 – Evert

回答

0

1)检查settings.py中的TEMPLATE_DIRS变量是什么。这是文件夹Django在每个应用程序中查找以查找您的模板。

2)尝试删除前面的斜线:

{% extends 'template1/personal/header.html' %}

3)如果模板1在TEMPLATE_DIRS,那么 '应用程序/ template.html' 就足够了

{% extends 'personal/header.html' %}

阅读上:

https://tutorial.djangogirls.org/en/template_extending/

https://docs.djangoproject.com/en/1.7/topics/templates/