Three ways to introduce static files:
One:<LinkRel="Stylesheet"href="/static/dd/ssmycss.css" >Two:{%Load static%}<Linkrel="stylesheet" href="{% static ' dd/ss/mycss.css '%}" >{# return value:/static/dd/ ss/mycss.css#} III:<link rel="stylesheet" href="{% get_static_prefix %}dd/ss/mycss.css ">
Template Import and inheritance
Template Import 1.Put the public part in the HTML, for example, called LEFT.HTML2.Where do you want to use{%Include ' left.html '%}Inheriting Master 1Write a master version of base.html 2Using the master version{%Block Base%}You can also write in the Master box.{%Endblock%}Pre-reserved Position 3Call: 3.1Write on the first line{%Extends ' base.html '%}3.2{%Block Base%} own stuff {% Endblock my_head%} alternate master reserved Locations 3.3 also want to use the content in the master ({{block.super}} Put in that, the original master of the things, will be rendered where) {% block Base%} {{block.super}} own stuff {% endblock my_head%} 3.4 box when inheriting, with order-independent
Custom Inclusion_tag
1Go to setting first.Inside the appName configuration on 2Re-appCreate a templatetags in the directoryModule 3Write pyFile (my_test.py) 4 from Django import Template5 register=template. Library () 6 @register. Inclusion_tag (' test.html ') def my_inclusion (n): data=[] for I in range (n): Data.append ('Section%sLine '%i ' return {' Data ':d ata}7Write test.htmlPage<ul> {% for choice in data%} <li>{{choice}}</li> {% endfor%}</ul>8 {% load my_test%}9 Span class= "Hljs-template-tag" >{% my_inclusion%}
Python Learning Day 73rd: template continuation