0

Sorry if my question is not well written or anything, this is my first time posting here. So, I'm trying Django and tries to use the generic templates of Django. I create a parent template named "layout.html". It has three blocks, then I created a child extended from this "layout.html", check the files :

layout.html :

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

etc...

index.html :

{% extends "layout.html" %}

{% block title %} My amazing index !!!{% endblock %}

etc...

These two files are in the same folder. But, here is my error :

TemplateDoesNotExist at /rubriques/

(yes, rubriques is my namespace)

Here is a sample of the error :

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

I hope someone can help me, I don't really see where the error comes from !

4

1 回答 1

2

您需要更改 settings.py 中的 TEMPLATES_DIR。

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

于 2013-05-21T10:57:38.563 回答