Reputation: 7645
I'm building a website in Django, and I want to have the main navbar and a side for finer detail.
I'm happy to hardcode the main navbar, but I'd like the sidebar to reflect the sections in the page (with anchor links to each).
I've seen mention of {{block.super}}
but that example is a little to abstract for me to understand how to apply it to my situation.
This is my sidebar:
<div id="sidebar-wrapper">
<ul class="sidebar-nav">
<li class="sidebar-brand">
<a href="#">
Website Title.
</a>
</li>
{%for section in page%}
<li>
<a href="#{{section.name}}">{{section.name}}</a>
</li>
</ul>
</div>
Do I need to extend this in my base.html? Or Do I extend my page template?
This is the body of my current base.html:
<body>
{% include 'navbar.html' %}
</div>
<div class="content container">
<div class="row">
<div class="col-md-8">
{% block content %}
{% endblock %}
</div>
</div>
</div>
</body>
I'm a little lost as how to implement this into my app. How should I be passing the content of my subpage into the navbar?
Upvotes: 2
Views: 1780
Reputation: 1353
You should write a different content block for the navbar in your base.html and override the block in your following templates file.
Upvotes: 1