python - Django - 扩展页面未填充
问题描述
我想用 header.html 的内容填充我的 index.html。
index.html 显示所有内容 - 除了 header.html 的内容。为什么不显示“Hello World”?
在 header.html 上,我还尝试引用“index.html”或“Immo/private/index.html”,但没有成功。
header.html:
{% extends 'private/index.html' %}
{% block content %}
<h1>fill: Hello World</h1>
{% endblock %}
索引.html:
{% load static %}
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Index-Page</title>
</head>
<body>
<div class="page-header">
<h1><a href="/">Index-Page</a></h1>
</div>
<div class="content container">
<div class="row">
<div class="col-md-8">
{% block content %}
{% endblock %}
</div>
</div>
</div>
</body>
</html>
设置.py:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates/')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
我在 Windows 上的 Visual Studio 上使用 django 2.1。
解决方案
推荐阅读
- python - 如何从 Docker 文件中的自定义文件通道安装 conda 包?
- python-3.x - 如何在 H2ODeepLearningEstimator 中使用提取隐藏层特征?
- python - 如何选择不在commonlist中的名称?
- php - 隐蔽的python代码加密到php代码加密
- python - 将列表中的每个条目单独添加到字符串
- domain-driven-design - 在 DDD 中聚合根实体
- types - 解决模块类型间接产生的类型错误
- javascript - JavaScript:日期时间字符串格式的数字数组
- html - 为什么即使宽度设置为 100%,我的网站边缘也会有间隙?
- spring-integration - Spring集成流程中如何处理FtpOutboundAdapter连接异常