A
A
Andrey Kovalchuk2017-02-22 16:25:02
Django
Andrey Kovalchuk, 2017-02-22 16:25:02

It's not clear how the template expands in django, what could be the problem?

Good day.
I'm templating html and came across an unexpected problem: the content is generated incorrectly from the parent template.
Here is base_admin.html

<!DOCTYPE html>
<html lang="ru-RU">
{% load staticfiles %}
{% block head %}
<head>
    {% block meta %}
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
        <meta name="description" content=""/>
        <meta name="author" content=""/>
    {% endblock %}
    {% block title %}
        <title>Free Responsive Admin Theme - ZONTAL</title>
    {% endblock %}
    {% block css %}
        <!-- BOOTSTRAP CORE STYLE  -->
        <link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet"/>
        <!-- FONT AWESOME ICONS  -->
        <link href="{% static 'css/admin/font-awesome.css' %}" rel="stylesheet"/>
        <!-- CUSTOM STYLE  -->
        <link href="{% static 'css/admin/admin.css' %}" rel="stylesheet"/>
    {% endblock %}

</head>
{% endblock %}
{% block body %}
<body>
<!-- LOGO HEADER END-->
{% block menu %}
    <section class="menu-section">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <div class="navbar-collapse collapse ">
                        <ul id="menu-top" class="nav navbar-nav navbar-right">
                            <li><a class="menu-top-active" href="admin_news.html">Dashboard</a></li>
                            <li><a href="ui.html">UI Elements</a></li>
                            <li><a href="table.html">Data Tables</a></li>
                            <li><a href="forms.html">Forms</a></li>
                            <li><a href="login.html">Login Page</a></li>
                            <li><a href="blank.html">Blank Page</a></li>

                        </ul>
                    </div>
                </div>

            </div>
        </div>
    </section>
{% endblock %}
<!-- MENU SECTION END-->
{% block content %}
    <div class="content-wrapper">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <h4 class="page-head-line">Dashboard</h4>

                </div>

            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="alert alert-success">
                        This is a simple admin template that can be used for your small project or may be large
                        projects.
                        This is free for personal and commercial use.
                    </div>
                </div>

            </div>
            <div class="col-md-12">
                <!--   Kitchen Sink -->
                <div class="panel panel-default">
                    <div class="panel-heading">
                        Новости
                    </div>
                    <div class="panel-body">
                        {% if news_list %}
                            <div class="table-responsive">
                                {% include 'adminApp/inc-news_list.html' %}
                            </div>
                        {% else %}
                            <p> Error! Objects not found.</p>
                        {% endif %}
                    </div>
                </div>
                <!-- End  Kitchen Sink -->
            </div>

        </div>
    </div>
{% endblock %}
<!-- CONTENT-WRAPPER SECTION END-->
{% block footer %}
    <footer>
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    &copy; 2015 YourCompany | By : <a href="http://www.designbootstrap.com/"
                                                      target="_blank">DesignBootstrap</a>
                </div>

            </div>
        </div>
    </footer>
{% endblock %}
{% block js %}
    <!-- FOOTER SECTION END-->
    <!-- JAVASCRIPT AT THE BOTTOM TO REDUCE THE LOADING TIME  -->
    <script src="{% static 'js/jquery-3.1.1.min.js' %}"></script>
    <script src="{% static 'js/bootstrap.min.js' %}"></script>
{% endblock %}
</body>
{% endblock %}
</html>

Here is the simplest version of the child file admin_news.html
{% extends 'adminApp/base_admin.html'%}
But here's what we get:
b58a0c18ad.jpg
And we wanted to get:
028d72259c.jpg
What went wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Kovalchuk, 2017-02-23
@mrkovalchuk

In general, the errors are divided in half: 1. Due to the fact that it was not registered - I entered it with pens into the child template; 2. Because of BOMs. It was decided by re-creating the files in the IDE.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question