Given this as your directory structure:
root/
γβ var/
γβγ β www/
γβγγγβ html/
γβγγγ β static
γβγγγ β βstyle.css
γβγγγ β βbase.js
γβγγγ β
γβγγγ β web/
γβγγγγγ βhead.html
γβγγγγγ βfooter.html
γβγγγγγ βbase.html
γβ
γβ opt/
γγγβ django/
γγγγγβ project/
γγγγγβ
γγγγγβ apps/
γγγγγβγβ views.py
γγγγγ γβ template/
γγγγγ γ β index.html
To use /var/www/html/web/head.html in your index.html. Go to your settings.py and add the following:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'apps/template'),'/var/www/html/web/']
,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
Now go to your index.html.
{% include "head.html" %}
Hope this helps.
source
share