Django-4

Master and inheritance:

Advantages: the plurality of extracted common part, reduced the rate of code reuse

Steps for usage:

1. html common portion is extracted, in which a base page

2. On base.html page, by defining a block, add something new to specify in what areas

3. In the specific page, to inherit the master {% extends 'base.html'%}

4. Then fill in the page specified in the block

Precautions:

1. {% Extends 'base.html'%} master file in quotes

2. {% Extends 'base.html'%} must be placed on the first line of the page

3. You can define a number of block in base.html usually we define an extra page-css, page-js

 

Components:

include in the master can easily put inside, but there needs to block in succession inside

 

 

Routing Problem static files:

In the HTML file under Templates, if you want to reference a static file under static

{% load static%}

<Link rel = 'stylesheet' href = '{%% static path static files}'>

This method solves the problem of different paths of different people can not find the naming conventions bring

Guess you like

Origin www.cnblogs.com/FlowerNotGiveYou/p/11417400.html