Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django TemplateDoesNotExist位于/website/,扩展模板_Django_Templates_Django Templates_Extends - Fatal编程技术网

Django TemplateDoesNotExist位于/website/,扩展模板

Django TemplateDoesNotExist位于/website/,扩展模板,django,templates,django-templates,extends,Django,Templates,Django Templates,Extends,对不起,如果我的问题写得不好或什么的,这是我第一次在这里发布。 因此,我正在尝试Django并尝试使用Django的通用模板。我创建了一个名为“layout.html”的父模板。 它有三个块,然后我创建了一个从这个“layout.html”扩展的子块,检查文件: layout.html: <!DOCTYPE html> <head> <link rel="stylesheet" href="style.css" /> <title>

对不起,如果我的问题写得不好或什么的,这是我第一次在这里发布。 因此,我正在尝试Django并尝试使用Django的通用模板。我创建了一个名为“layout.html”的父模板。 它有三个块,然后我创建了一个从这个“layout.html”扩展的子块,检查文件:

layout.html:

<!DOCTYPE html>
<head>
    <link rel="stylesheet" href="style.css" />
    <title>{% block title %}Bleh bleh{% endblock %}</title>
</head>
等等

这两个文件位于同一文件夹中。但是,我的错误是:

TemplateDoesNotExist at /rubriques/
(是的,rubriques是我的命名空间)

以下是错误示例:

Request URL:    http://127.0.0.1:8000/rubriques/
Django Version:     1.5.1
Exception Type:     TemplateDoesNotExist
Exception Value:    

layout.html

Exception Location:     /home/thomas/.virtualenvs/site/local/lib/python2.7/site-packages/django/template/loader.py in find_template, line 139
Python Executable:  /home/thomas/.virtualenvs/site/bin/python
Python Version:     2.7.4


Error during template rendering

In template /home/thomas/projets/siteonglets/rubriques/templates/rubriques/index.html, error at line 1

我希望有人能帮助我,我真的不明白错误是从哪里来的

您需要更改settings.py中的TEMPLATES\u DIR


这样django就会知道模板在哪里。

你能发布你的
视图吗?还有
settings.py
中的
TEMPLATE\u DIRS
设置。在index.html模板
{%extends'rubriques/layout.html%}
中执行此操作可能会更正此问题。问题在模板\u DIRS中。谢谢你的帮助!嘿,这么简单?非常感谢,没有你我找不到。它起作用了!
Request URL:    http://127.0.0.1:8000/rubriques/
Django Version:     1.5.1
Exception Type:     TemplateDoesNotExist
Exception Value:    

layout.html

Exception Location:     /home/thomas/.virtualenvs/site/local/lib/python2.7/site-packages/django/template/loader.py in find_template, line 139
Python Executable:  /home/thomas/.virtualenvs/site/bin/python
Python Version:     2.7.4


Error during template rendering

In template /home/thomas/projets/siteonglets/rubriques/templates/rubriques/index.html, error at line 1