Home > Mobile >  footer.html is not included when extending the base.html file
footer.html is not included when extending the base.html file

Time:07-27

In header.html, I have

<h1>Header Section</h1>

In footer.html, I have

<h1>Footer Section</h1>

In base.html I have

{% include 'header.html'%}
{% block content %} 
{% endblock %}
{% include
'footer.html' %}

But when I extend the base template, I only get the header and the content of the page which extends the base. The footer section appears as {% include 'footer.html' %}

Why is that?

CodePudding user response:

Don't use multiple lines. The Django template engine can not parse this (properly). Put the entire {% include … %} [Django-doc] template tag on a single line:

{% include 'header.html'%}
{% block content %} 
{% endblock %}
{% include 'footer.html' %}
  • Related