I have base.html that loads basically whole site. Inside that base.html I want to hide on home page, but not on others. How to do this?
Tried to do like this, but something messed up...
This is base.html (This is a part I want to hide in home.html)
{% block header_parent %}
<!-- ***** Breadcumb Area Start ***** -->
<div class="mosh-breadcumb-area" style="background-image: url({% static 'img/core-img/breadcumb.png' %})">
<div class="container h-100">
<div class="row h-100 align-items-center">
<div class="col-12">
<div class="bradcumbContent">
<h2>{{page_title}}</h2>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{% url 'home' %}">Home</a></li>
<li class="breadcrumb-item active" aria-current="page">{{page_title}}</li>
</ol>
</nav>
</div>
</div>
</div>
</div>
</div>
<!-- ***** Breadcumb Area End ***** -->
{% endblock %}
Page with header
{% extends "base.html" %}
{% load static %}
{% block content %}
{% block header %}{% endblock %}
<p>Every other page.</p>
{% endblock content %}
This is home.html (I don't want to be show part of header here)
{% extends "base.html" %}
{% load static %}
{% block content %}
<p>Home</p>
{% endblock content %}
CodePudding user response:
To hide a portion of a template to extend :
You just have to explicitly call the block tag with nothing inside it. In your home.html :
{% extends "base.html" %}
{% load static %}
{% block header_parent %}
<!-- Nothing here (to override this portion defined in the parent template) -->
{% endblock %}