我不明白为什么我收到此错误“第29行上的无效块标记:'包含',预期'endblock'。您是否忘记注册或加载此标记?”第29行是我将{%include%}标记放在INDEX.HTML文件中的行。下面的两个html文件都在同一目录中。
INDEX.HTML文件
{% extends './base.html' %}
{% load staticfiles %}
{% block head_js %}
{% endblock %}
{% block content %}
<!-- Page Content -->
<div>
<!-- Header/Home -->
<header class="w3-container w3-padding-32 w3-center w3-black" id="home">
<h1 class="w3-jumbo"><span class="w3-hide-small">Cricket Scorer</span></h1>
<p>A Simple Cricket Scoring Web App</p>
</header>
<!-- Selection Menu -->
<div class="w3-content w3-justify w3-text-grey w3-padding-64">
<!--button type="button" class="btn btn-default btn-lg btn-block" data-toggle="modal" data-target="#match-details" onclick="alert('here');">Start Scoring</button><br-->
<button type="button" class="btn btn-default btn-lg btn-block" data-toggle="modal" data-target="#select-home-team">Start Scoring</button><br>
<button type="button" class="btn btn-default btn-lg btn-block">Players</button><br>
<button type="button" class="btn btn-default btn-lg btn-block">Teams</button>
</div>
</div>
{% includes "start_scoring_modal.html" %}
{% endblock %}
START_SCORING_MODAL.HTML
{% extends './index.html' %}
{% load staticfiles %}
<!-- Modal Boxes -->
<div class="modal fade" id="select-home-team" role="dialog">
<div class="modal-dialog modal-bg">
<div class="modal-content">
...
...
...
...
=============================================== ========================= 上面的错误是我使用“includes”而不是“include”错误地使用语法。现在我有一个新错误。 index.html给出TemplateDoesNotExist错误,并标记第1行“{%extends”./ base.html“%}”。
但是,如果我删除带有“include”的行,它将正常工作。太过困惑!!
{% extends "./base.html" %}
{% load staticfiles %}
{% comment %} http://www.webhook.com/docs/template-inheritance-blocks/ {% endcomment %}
{% block head_js %}
{% endblock %}
{% block content %}
<!-- Page Content -->
<div>
<!-- Header/Home -->
<header class="w3-container w3-padding-32 w3-center w3-black" id="home">
<h1 class="w3-jumbo"><span class="w3-hide-small">Cricket Scorer</span></h1>
<p>A Simple Cricket Scoring Web App</p>
</header>
<!-- Selection Menu -->
<div class="w3-content w3-justify w3-text-grey w3-padding-64">
<!--button type="button" class="btn btn-default btn-lg btn-block" data-toggle="modal" data-target="#match-details" onclick="alert('here');">Start Scoring</button><br-->
<button type="button" class="btn btn-default btn-lg btn-block" data-toggle="modal" data-target="#select-home-team">Start Scoring</button><br>
<button type="button" class="btn btn-default btn-lg btn-block">Players</button><br>
<button type="button" class="btn btn-default btn-lg btn-block">Teams</button>
</div>
</div>
{% include "./start_scoring_modal.html" %}
{% endblock %}
答案 0 :(得分:0)
您的{% extends './index.html' %}
文件中不需要start_scoring_modal.html
。
您只需要在start_scoring_modal.html
中导入添加的代码,这样就不需要扩展index.html
。