user3043594
user3043594

Reputation: 166

HTML Docs can't find

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 %}
                &copy; 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

Answers (2)

Anentropic
Anentropic

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

Steinar Lima
Steinar Lima

Reputation: 7821

These are Django template tags. Check out the documentation.

Upvotes: 1

Related Questions