服务器工作正常,但是使用此'home.html'文件的扩展无法链接模板:
在'home.html'中:
{%extends“/template1/personal/header.html”%}加载localhost时:Django尝试按以下顺序加载这些模板:
`使用引擎django:
-
django.template.loaders.app_directories.Loader:/usr/local/lib/python2.7/dist-packages/django/contrib/admin/templates/ffgg/home.html(源不存在) .
-
django.template.loaders.app_directories.Loader:/usr/local/lib/python2.7/dist-packages/django/contrib/auth/templates/ffgg/home.html(来源不存在)
1 回答
1)检查settings.py中的TEMPLATE_DIRS变量中的内容 . 这是Django在每个应用程序中查找的文件夹,以便找到您的模板 .
2)尝试删除前导斜杠:
{% extends 'template1/personal/header.html' %}
3)如果template1在TEMPLATE_DIRS中,那么'app / template.html'就足够了
{% extends 'personal/header.html' %}
继续阅读:
https://tutorial.djangogirls.org/en/template_extending/
https://docs.djangoproject.com/en/1.7/topics/templates/