Django learning manual – template inheritance and import

Core:

PS:A page can only inherit one template.

Preposition:

  Configure URL.

Configuring views

 

  Keyword:

  1.  {% extends "indexTemplate.Html " %} Which template is inherited from which template to associate with which template page.
  2.  
{% block title %}<h1>User management page: < /h1>{% endblock %} The contents of the main page are written. Template pages need to be added to the location only.
  3.  
{% include "index-Import.Html " %} You can import directly on the main page.



indexpage
{#Which web page does the statement inherit?{%extends "indexTemplate.Html " %}
{#A page can only inherit one template.PS:CSS can be written directly into the template or JS code path.{% block CSS%} {% endblock%}{% block JSS% {endblo% {%CK%}{% block title %}
    <h1>User management page:</h1>
{% endblock %}

{#    Template added{% blockcontent %}
    <ul>
        {% for i in dict_list %}
            <li>
                {{ i.keys }}
            </li>
        {% endfor %}
    </ul>

    <div>
        Secondary template to main page.{% include"index-Import.Html " %}

    </div>
{% endblock %}

Inherited template:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body style="margin: 0;background-color: aqua">
            {#    Declare template location{% blocktitle %}{% endblock %}
            {#    Declare template location{% block content %}{% endblock %}
</body>
</html>

Templates need to be imported:

<div>
    <ul>
        <li>
            1
        </li>
        <li>
            1
        </li><li>
            1
        </li><li>
            1
        </li>
    </ul>
</div>

 

Test:

 

Leave a Reply

Your email address will not be published. Required fields are marked *