【问题标题】:after extending base.html ,my child html thiings are not showing扩展 base.html 后,我的孩子 html 的东西没有显示
【发布时间】:2019-05-24 07:19:32
【问题描述】:

在扩展之前我检查了所有连接和文件路径,但在扩展我的子代码后消失了

base.html

<!DOCTYPE html>
{% load staticfiles%}
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="icon" type="image/x-icon" href="{% static '/images/icon.png' %}" />
<title>allgood.com</title>
<link href="{% static "/css/base.css" %}" rel="stylesheet" 
type="text/css"/>
</head>
<body>
<div class="header">
<span class="name">allgood</span>
<button class="btn1 ">Resume</button>
<button class="btn2 ">resume</button>
<span class="profileimage"><img src="{%static '/images/profile1.png' 
%}"  style="width:40px;height:40px"></span>

</div>
</body>
</html>

技能.html

{% extends 'app/base.html' %}

 {% block content %}
 <p>skills</p>
 <p>skills</p>
 <p>skills</p>
 {% endblock %}

【问题讨论】:

  • 但是你的base.html中没有添加{% block content %}和{% endblock %}

标签: html django django-templates django-views


【解决方案1】:

您的base.html 文件仍应包含块部分

<!DOCTYPE html>
{% load staticfiles%}
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="icon" type="image/x-icon" href="{% static '/images/icon.png' %}" />
<title>allgood.com</title>
<link href="{% static "/css/base.css" %}" rel="stylesheet" 
type="text/css"/>
</head>
<body>
<div class="header">
<span class="name">allgood</span>
<button class="btn1 ">Resume</button>
<button class="btn2 ">resume</button>
<span class="profileimage"><img src="{%static '/images/profile1.png' 
%}"  style="width:40px;height:40px"></span>
   {% block content %}
   {% endblock %}
</div>
</body>
</html>

【讨论】:

    猜你喜欢
    • 2014-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多