Y
Y
Yura Khlyan2019-04-22 12:38:09
Django
Yura Khlyan, 2019-04-22 12:38:09

How to properly work with templates in Django?

Good day.
I have a template structure like this (Django-Wagtail):
base.html

<!DOCTYPE html>
<html class="no-js" lang="en">
    <head>
        ...
    </head>

    <body class="{% block body_class %}{% endblock %}">
        <header class="header">
            {% block navigation %}
                {% include "partials/navigation.html" %}
            {% endblock navigation %}
        </header>

        <main class="main">
            {% block content %}{% endblock %}
        </main>

        {% block footer %}
            {% include "partials/footer.html" %}
        {% endblock footer %}

        {% block extra_js %}{% endblock %}
    </body>
</html>

footer.html:
<footer class="footer ">
    <div class="container">
        
        {% block contact_us_form %}
        {% endblock contact_us_form %}

        <div class="footer__request">
        </div>

        <div class="footer__colophon">
            <div></div>
            <div> </div>
        </div>

    </div>
</footer>

home.html:
{% extends "base.html" %}

{% block content %}
    Content here
{% endblock content %}

{% block contact_us_form %}
    Code for form
{% endblock contact_us_form %}

I want the home page to have a contact form in the footer. How to do this there are many options. I just want to make it beautiful in templates, blocks. But the way I mentioned above doesn't work. I can't change the block contact_us_formon the home page in any way.
Is it possible to do this at all, or is it impossible to change a block within a block?
I will be grateful for help.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question