For example I have top.html which will be included from within base.html.
How to override contents of top.html after including?
1 Answer
You didn't understand templates idealogy.
Right way is create base.html like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Some app - {% block header %}{% endblock %}</title>
</head>
<body>
<h1>{% block title %}Default title{% endblock %}</h1>
{% block content %}{% endblock %}
</body>
</html>
And then in page.html you can override header for example:
{% extends "base.html" %}
{% block title %}Some page{% endblock %}
{% block header %}Overriden header{% endblock %}
{% block content %}
Some content
{% endblock %}
1 Comment
sultan
I figured it out, thanks @Stanislav Feldman though the examples do not satisfy my requirements)