I have a folder, templates, structured like below
/Users/AndyKw/Documents/Python/Else/Yes/templates
Within templates
, I have two folders, admin
and registration
(see below for the tree)
templates (need.html)
|
|-- admin
|
|-- registration (base.html)
The file I use base.html
is in the folder registration
. It needs to use a file , need.html
in the folder templates
with the extends
command.
Question is the following:
templates
parameter to use registration
as the main folder and
through base.html
to reach by using extends
the file need.html
in the templates
folder?One possible solution would be to invert the path, put need.html
in the registration
folder and put the base.html
in the templates
folder but the dev team seems to be quite unbending on this solution, this would be the less favourable way.
Any ideas/tips are welcomed.
In settings.py:
TEMPLATES = [
{
'DIRS': [
os.path.join(BASE_DIR, 'templates')
],
...
}
]
Then in need.html:
<head>
<!-- common headers for all templates -->
{% block head %}
{% endblock %}
</head>
<body>
<!-- common body for all template -->
{% block body %}
{% endblock %}
</body>
Then in all your templates:
{% extends "need.html" %}
{% block head %}
<!-- headers here -->
{% endblock %}
{% block body %}
<!-- body here -->
{% endblock %}