I am trying to incorporate a django application into a web site where static html accounts for the majority. The directory structure is as follows.
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
I want to make /opt/django/template/index.html
read html in /var/www/html/web/
.
I do not know how to include.
{% include "/var/www/html/web/head.html" %}
was useless.
I do not want to change the directory structure.
Considering 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 this:
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" %}
I hope this will help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With