2013-05-02 108 views
1

我試圖將'comment.html'包含到store.html和store.html extend base.html中。Django包含無法找到模板

但Django是拋出錯誤comment.html (<class 'django.template.base.TemplateDoesNotExist'>)

所有模板都在同一目錄。 store.html工作正常,當我包括comment.htmlstore.html錯誤拋出... 我用{% include "comment.html" %}這包括comment.htmlstore.html它是正確擴展base.html沒有任何問題。但

迪爾棵樹,這些文件位於: vaibhav @ ubuntu:〜/ TRAC/bright-coupons/brightCoupons/brightCouponsApp $ tree 。

├── __init__.py 
├── models.py 
├── templates 
│   ├── about.html 
│   ├── base.html 
│   ├── comment.html 
│   ├── contact.html 
│   ├── error.html 
│   ├── index.html 
│   ├── index-var.html 
│   ├── store.html 
│   ├── stores.html 
│   ├── submit-form.php 
│   ├── support.html 
│   └── tags.html 
├── tests.py 
├── views.py 
+0

重新檢查文件名。 – Rohan 2013-05-02 10:01:41

+0

did..checked ...在Django擴展和包含在相同的模板是否支持? – 2013-05-02 10:04:07

+0

是的,它是支持的,不應該是問題。你的'{%extend%}'行是什麼? – Rohan 2013-05-02 10:10:57

回答

2

請注意,如果確實包含,則必須將路徑相對於模板目錄的根目錄。所以,如果comment.html駐留在TEMPLATE_BASE_DIR /應用/ comments.html你要做的

{% include "app/comments.html" %} 

的路徑是不是相對於包括模板的位置(因爲包括模板可以爲此事的字符串。 ..)

+0

我已嘗試通過將...但它拋出同樣error..anyway'comment.html'的模板內我的應用程序內的目錄和所有其他的模板也是在模板目錄,可... – 2013-05-02 10:13:15

+0

爲了包括模板是否有任何你需要在包含的模板中指定...我的意思是在comment.html中是否有任何需要指定的... – 2013-05-02 11:07:53

+0

不,它可以是任何適合外層模板的東西。 你有沒有試過包括base.html,看看你是否得到相同的錯誤? (當然這不會產生一個合理的模板,雖然...) – related 2013-05-02 11:15:09