2012-03-13 96 views
0

我試圖從模板擴展,並且保持相同TemplateDoesNotExist錯誤。所有其他頁面,不擴展的基本模板的工作(他們只是有一些虛擬的HTML)TemplateDoesNotExist雖然文件存在並且權限正確

我做了一個ls -l命令和文件存在,並且所有的權限idential:

-rw-r--r-- 1 atrus users 1625 Mar 13 13:05 base.html 
drwxr-xr-x 2 atrus users 4096 Mar 13 10:50 css 
drwxr-xr-x 2 atrus users 4096 Mar 13 10:51 img 
-rw-r--r-- 1 atrus users 136 Mar 13 13:14 index.html 
-rw-r--r-- 1 atrus users 407 Mar 12 12:16 login.html 
-rw-r--r-- 1 atrus users 662 Mar 12 03:21 register.html 
-rw-r--r-- 1 atrus users 59 Mar 12 02:41 temp.html 

所以它不是一個權限問題,並將該文件(base.html文件存在)

那我打電話(指數)

我的看法很簡單:

def index(request): 
    return render_to_response('menu/index.html') 

和我的index.html如下:

{% extends 'base.html' %} 

{% block title %}Home{% endblock title %} 

{% block content %} 
<p>here be content <p> 
{% endblock content %} 

錯誤發生在第一行。

我的settings.py的TEMPLATE_DIRS是:

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". 
    # Always use forward slashes, even on Windows. 
    # Don't forget to use absolute paths, not relative paths. 
    '/home/atrus/Dropbox/workspace/menu/menu/templates' 
) 
+0

「settings.py」中的'TEMPLATE_DIRS'看起來像什麼? – 2012-03-13 17:41:31

+0

你應該在'TEMPLATE_DIRS'中有'.../menu/menu/...'嗎?不知道這是一個錯字還是實際的設置 – 2012-03-13 17:53:24

回答

1

它看起來並不像你有一個menu目錄內您模板文件夾中(假設這就是你做了ls)。你有沒有試過只是做return render_to_response('index.html')

此外,正如我的評論所述,是你的TEMPLATE_DIRS正確的文件路徑?我不知道當你離開了評論,如果你不期而遇複製「菜單中的」

+0

你是對的,它在子文件夾中,那不是直接在TEMPLATE_DIRS中。 是的,菜單/菜單是正確的。只是一件創造物,在我的小項目上工作時,對我而言,這並不是一個足夠大的交易。 – Atrus 2012-03-13 18:58:26

1

,你TEMPLATE_DIRS設置僅僅是這樣的:

TEMPLATE_DIRS = ('/home/atrus/Dropbox/workspace/menu/menu/templates') 

這實際上是一個字符串,而不是一個元組。您需要逗號:

TEMPLATE_DIRS = ('/home/atrus/Dropbox/workspace/menu/menu/templates',) 
相關問題