Skip to content

Instantly share code, notes, and snippets.

@monokrome
Last active July 10, 2017 03:10
Show Gist options
  • Save monokrome/5447258 to your computer and use it in GitHub Desktop.
Save monokrome/5447258 to your computer and use it in GitHub Desktop.
Django template inheritance example
<!DOCTYPE html>
<html>
<head>
<title>{% block page_title %}{% endblock page_title %}</title>
</head>
<body>
{% block document_body %}
<div id=document-container>{% block document_container %}{% endblock document_container %}</div>
<footer id=document-footer>{% block document_footer %}{% endblock document_footer %}</footer>
{% endblock document_body %}
</body>
</html>
{% extends "base.html" %}
{% block page_title %}Page Title{% endblock page_title %}
{% block document_footer %}Page Footer{% endblock document_footer %}
{% extends "base_site.html" %}
{% block document_container %}
<h1>Welcome to my site!</h1>
{% endblock document_container %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment