Reputation: 31548
I have folder called mytemplates for sites base templates
Project ----App1,App2,App3,static
Now in my static folder i have folder called mytemplates/temp1/index.html
Now in my app1
app1/templates/app1/index.html
I want to do this
{% extends "/static/mytemplates/temp1/index.html" %}
But its saying that template not found
Upvotes: 1
Views: 2022
Reputation: 2972
You don't need to write /static
.
You must have your /static
folder defined in settings.TEMPLATE_DIRS
otherwise django's template loader will never search there. You must write out the full path, not the relative path.
By default, template loaders search inside of the template folder, so they don't depend on which template folder they are in. Meaning, writing {% extends "mytemplates/temp1/index.html" %}
will result in django making a list of all your template dirs, appending mytemplates/temp1/index.html
to the absolute path of each, and determining whether or not the concatenated path exists. If it doesn't, it keeps trying your other template directories. If after trying all your directories no match is found, django raises an exception.
Writing simply {% extends "mytemplates/temp1/index.html" %}
will work assuming your static
folder is in your settings.TEMPLATES_DIR
tuple and that "mytemplates/temp1/index.html"
exists in static
.
Upvotes: 3
Reputation: 799
You don't put a full pathname to the file in, look here for the exact syntax. If's the same name that you would call your template from your view.
Upvotes: 0