I learnt about Django template inheritance and was working on it.
I made a base_post_login.html
template in the same directory as other templates.
and type {% extends "base_post_login.html" %}
as the first line in in a child template.
But when the child template is rendered through back-end the TemplateDoesNotExist
error is raised.
this is settings.py(relevant part):
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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',
],
},
},
]
all templates are rendered properly if it does not extend and parent template.
What should I do?
You are using Django extends the wrong way, it should take the parent template name so do this:
{% extends "base.html" %}
EDIT
OK I see, you should use the template path like you do when you render your other templates:
Let's say you render like this "templates/child_page.html" then you should extend the same way
{% extends "templates/base.html" %}