1. Page reuse & share page
Page reuse is to extract the same part of each page of the website as a shared page . When you need to modify the shared part of each page, you only need to modify the shared page.
2. Template tags
Template tags for page reuse have two
(1) inheritance tags
{% extends "base.html" %}
(2) Dynamic content declaration label
{% block title %}
{% endblock %}
{% block content %}
{% endblock %}
block and endblock are fixed label statements
3. Possible errors
Error: Prompt that the template file cannot be found
Reason: Django provides a default template search path, which is to look for the templates folder under each application, not in the root directory.
Method: If base.html is built in the templates folder of the root directory, it needs to be set in settings.py, and the templates folder under the project root directory BASE_DIR is added to the template search path.
Edit the settings.py under the [Project Name] folder, find the templates field, and modify DIRS:
'DIRS': [os.path.join(BASE_DIR, 'templates')],