-
-
Save iamshacky/7b974f1d190054becdd81c78ae4b5076 to your computer and use it in GitHub Desktop.
Multiple and extending base templates in Django
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Foo</title> | |
</head> | |
<body> | |
<header> | |
{% block header %} | |
<h1>Lorem ipsum</h1> | |
{% endblock %} | |
</header> | |
{% block content %}{% comment %}A wrapper around content is needed{% endcomment %} | |
<div class="page-content"> | |
{% block page_content %}{% comment %} Filled in by your page templates {% endcomment %} | |
{% endblock %} | |
</div> | |
{% endblock %} | |
<footer> | |
{% block footer %} | |
<em>♥ joar</em> | |
{% endblock footer %} | |
</footer> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'base.html' %} | |
{% block content %} | |
<div class="page-content"> | |
{% block page_content %}{% comment %} Filled in by your page templates {% endcomment %} | |
{% endblock %} | |
{% block comments %} | |
<footer> | |
<h2>Comments</h2> | |
<script>loadCommentsEtc()</script> | |
</footer> | |
{% endblock %} | |
</div> | |
{% endblock %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'base-comments.html' %} | |
{% block page_content %} | |
<article> | |
<h1>{{ post.title }}</h1> | |
<div class="post-body"> | |
{{ post.body }} | |
</div> | |
</article> | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment