L
L
leha782016-04-19 08:20:25
Django
leha78, 2016-04-19 08:20:25

How do you add blocks to the right and left columns of the site?

There was such a question.
I have a main base.html file that contains all the content through:
{% block content %}
{% endblock %
} the same part (side) will have other information. Would it be correct to lay out these blocks separately inside classifieds.html and yellowpages.html without touching base.html at all?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Melnikov, 2016-04-19
@leha78

It is not entirely clear how the templates are made, in base.html you specify the blocks that you will redefine in inherited templates, you need to specify even if there is no content in it. For example, you define in base.html

{% block left_column %}
{% endblock %}

and in the successor, for example, you display your ads
{% block left_column %}
    {% for item in advertisements %}
        {{ item.text }}
    {% endfor %}
{% endblock %}

In this case, the contents of the base.html block will be completely redefined.
On another page, you override it again with different content.

A
Artem, 2016-04-19
@ulkoart

you can try

{% include "page.html" %}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question