1

I am trying to include 'comment.html' into store.html and store.html extend base.html.

But Django is throwing error comment.html (<class 'django.template.base.TemplateDoesNotExist'>)

All templates are in the same Dir. store.html works fine and it is extending base.html properly without any problem.But when i included comment.html in store.html the error is thrown... I have used {% include "comment.html" %} this to include comment.html into store.html

Dir tree where these files are located: 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
Vaibhav Jain
  • 5,287
  • 10
  • 54
  • 114

1 Answers1

4

Note that when you do include to you have to put the path relative to the root of the template dir. So if comment.html resides in TEMPLATE_BASE_DIR/app/comments.html you have to do

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

the paths is not relative to the location of the including template (since the including template could be a string for that matter...)

related
  • 794
  • 5
  • 14
  • i have tried that by putting...but it is throwing same error..anyway `comment.html` is inside templates dir within my app and all other templates are also inside the templates dir... – Vaibhav Jain May 02 '13 at 10:13
  • in order to include template is there anything you need to specify inside the included template...i mean in comment.html is there anything need to be specified... – Vaibhav Jain May 02 '13 at 11:07
  • No, it can be anything that fits into the outer template. Have you tried including base.html to see if you get the same error? (of course that wouldn't produce a sensible template though...) – related May 02 '13 at 11:15
  • Well then try copying comment.html to bla.html, and then try to include bla.html - or try deleting the file and recreating it... (You need to isolete whether this is a problem with the file's content (doesn't make sense though), the file's path or the file itself...) – related May 02 '13 at 11:55
  • I did not understand it is including any other page but not comment.html....is their anything wrong with the syntax of comment.html please have a look at comment.html....here http://notepad.cc/hookeave51 – Vaibhav Jain May 02 '13 at 12:03
  • actually i want this to refresh the particular div not the whole page ...on some certain event ....can you tell me is there any other way of doing that... – Vaibhav Jain May 02 '13 at 12:05
  • You'll need to use ajax for that - something like http://stackoverflow.com/questions/3583534/refresh-div-element-generated-by-a-django-template – related May 02 '13 at 12:13