I have a project with the following structure:
project
project
static/
templates
project
base.html
__init__.py
.....
events
static/
templates
events
events.html
__init__.py
models.py
.....
I want to extend base.html in events.html
I tried with:
{% extends "project:project/base.html" %}
But get the following error:
Exception Type: TemplateDoesNotExist
Exception Value: project:project/base.html
Also tried with:
{% extends "base.html" %}
But the same error is returned:
Exception Type: TemplateDoesNotExist
Exception Value: base.html
In INSTALLED_APPS I have:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'events',
'project',
)
TEMPLATE_DIRS and BASE_DIR:
TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
In TEMPLATE_LOADERS I have:
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
Your TEMPLATE_DIR is set to project/templates, not project/templates/project.
Since there is no base.html in project/templates, Django returns an error.
You could either move base.html up to project/templates, or reference it by writing :
{% extends "project/base.html" %}
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