我正在尝试使用extends tag
来简化我的HTML files
,并且主要不会写几次同样的事情。
所以我创建了一个Base.html
文件和Home.html
位于:
Etat_civil
|__Home
|__templates
|__Home.html
|__BirthCertificate
|__Identity
|__templates
|__Base.html
这是我的 Base.html 文件:
<!--DOCTYPE html -->
<html>
<head>
{% load staticfiles %}
<title> DatasystemsEC - Accueil </title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="{% static 'css/Base.css' %}"/>
</head>
<!-- #################### -->
<!-- Upper navigation bar -->
<!-- #################### -->
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="http://www.datasystems.fr/"> DatasystemsEC </a>
</div>
<!-- Home tab -->
<ul class="nav navbar-nav">
<li><a href="{% url "accueil" %}"> <span class="glyphicon glyphicon-home"></span> Accueil </a></li>
<!-- Individual form tab -->
<li class = "dropdown">
<a href = "accueil" class = "dropdown-toggle" data-toggle = "dropdown">
<span class="glyphicon glyphicon-baby-formula"></span> Fiches Individuelles
<b class = "caret"></b>
</a>
<ul class = "dropdown-menu">
<li><a href = "{% url "home" %}"> Accueil des fiches individuelles </a></li>
<li><a href = "{% url "form" %}"> Création des fiches individuelles </a></li>
<li><a href = "{% url "searched" %}"> Consultation des fiches individuelles </a></li>
<li><a href = "{% url "edited" %}"> Edition des fiches individuelles </a></li>
<li><a href = "{% url "deleted" %}"> Suppression des fiches individuelles </a></li>
</ul>
</li>
<!-- Birth form tab -->
<li class = "dropdown">
<a href = "accueil" class = "dropdown-toggle" data-toggle = "dropdown">
<span class="glyphicon glyphicon-baby-formula"></span> Actes de Naissance
<b class = "caret"></b>
</a>
<ul class = "dropdown-menu">
<li><a href = "{% url "BChome" %}"> Accueil des actes de naissance </a></li>
<li><a href = "{% url "BCform" %}"> Création d'un acte de naissance </a></li>
<li><a href = "{% url "BCnotfound" %}"> Consultation d'un acte de naissance </a></li>
<li><a href = "{% url "BCnotfound" %}"> Edition d'un acte de naissance </a></li>
</ul>
</li>
<!-- Wedding form tab -->
<li class = "dropdown">
<a href = "accueil" class = "dropdown-toggle" data-toggle = "dropdown">
<span class="glyphicon glyphicon-heart"></span> Actes de Mariage
<b class = "caret"></b>
</a>
<ul class = "dropdown-menu">
<li><a href = "{% url "BCnotfound" %}"> Accueil des actes de mariage </a></li>
<li><a href = "{% url "BCnotfound" %}"> Création des actes de mariage </a></li>
<li><a href = "{% url "BCnotfound" %}"> Consultation des actes de mariage </a></li>
<li><a href = "{% url "BCnotfound" %}"> Edition des actes de mariage </a></li>
</ul>
</li>
<!-- Divorce form tab -->
<li class = "dropdown">
<a href = "accueil" class = "dropdown-toggle" data-toggle = "dropdown">
<span class="glyphicon glyphicon-fire"></span> Actes de Divorce
<b class = "caret"></b>
</a>
<ul class = "dropdown-menu">
<li><a href = "{% url "BCnotfound" %}"> Accueil des actes de divorce </a></li>
<li><a href = "{% url "BCnotfound" %}"> Création des actes de divorce </a></li>
<li><a href = "{% url "BCnotfound" %}"> Consultation des actes de divorce </a></li>
<li><a href = "{% url "BCnotfound" %}"> Edition des actes de divorce </a></li>
</ul>
</li>
<!-- Death form tab -->
<li class = "dropdown">
<a href = "accueil" class = "dropdown-toggle" data-toggle = "dropdown">
<span class="glyphicon glyphicon-alert"></span> Actes de Décès
<b class = "caret"></b>
</a>
<ul class = "dropdown-menu">
<li><a href = "{% url "BCnotfound" %}"> Accueil des actes de décès </a></li>
<li><a href = "{% url "BCnotfound" %}"> Création des actes de décès </a></li>
<li><a href = "{% url "BCnotfound" %}"> Consultation des actes de décès </a></li>
<li><a href = "{% url "BCnotfound" %}"> Edition des actes de décès </a></li>
</ul>
</li>
</ul>
<!-- Connexion tab -->
<ul class="nav navbar-nav navbar-right">
<li><a href="http://localhost:8000/admin/login/?next=/admin/"><span class="glyphicon glyphicon-log-in"></span> Me Connecter </a></li>
</ul>
</div>
</nav>
</html>
我的 Home.html 文件:
{% extends 'Base.html' %}
{% load staticfiles %}
{% block content %}
<!-- ############### -->
<!-- Page principale -->
<!-- ############### -->
<p align="center"><img src="{% static 'images/logo.png' %}"></p>
<h2 align="center"> <font color="#0083A2"> Bienvenue sur la page d'accueil du logiciel DatasystemsEC </font></align></h2>
{% endblock content %}
我正确使用了我的base.html,但内部没有任何内容。我应该看到我的Home.html文件带有图片和标题吗?
Base.html正在覆盖我的Home.html文件?
我可以粘贴我的settings.py文件,以便在需要时查看模板和静态目录,但我看不到问题所在。
谢谢!
答案 0 :(得分:2)
你没有&#34;内容&#34;阻止你的base.html模板,显然你不能在&#34; home.html&#34;中覆盖它。我们的想法是使用基本模板来定义公共页面结构,使用(通常为空)块作为占位符,即&#34;具体&#34;模板将填写。 IOW:你必须添加一个空的&#34;内容&#34;阻止您希望内容显示的基本模板;)