Reputation: 166
I'm looking for docs that discuss what these things are:
base.html
<html>
<head>
{% block head %}
<title>My Site - {% block title %}{% endblock %}</title>
{% endblock %}
</head>
<body>
<div id="content">
{% block content %}
{% endblock %}
</div>
<div id="footer">
{% block footer %}
© Copyright 2014 by <a href="http://www.youtube.com/watch?v=dQw4w9WgXcQ">Me</a>.
{% endblock %}
</div>
</body>
</html>
Specifically things like:
{% block content %}
{% endblock %}
I'm trying to understand where I would place my CSS stylesheets and other elements into the base.html
For example where would I place a menu system that spans across all of my pages in my base.html
Are there any docs on this subject. I can't seem to find anything other than w3fools...
Upvotes: 1
Views: 65
Reputation: 33863
Django has excellent documentation which is easy to find:
https://docs.djangoproject.com/en/dev/topics/templates/
Your base.html
will contain the HTML code that is common across all the templates that are based on it (templates which use {% extends "base.html" %}
)
It's up to you to decide what belongs there. But typically it will be the 'skeleton' of the page, the base.html you have posted in the question is a good example of a base template.
The {% block ____ %}
tags define a place in the template where extending templates can substitute their own content. So, for example, where you have:
<div id="content">
{% block content %}
{% endblock %}
</div>
...the extending template can contain just:
{% block content %}
some content here
{% endblock %}
and when rendered you get:
<div id="content">
some content here
</div>
Upvotes: 2