Django:第41行的无效代码块:“ endblock”,应为“ empty”或“ endfor”

时间:2019-05-14 09:36:34

标签: django django-templates

我现在正在从事一个项目,特别是在CRUD阶段。我也是Django框架的新手,但我了解一些基本知识。我按照手册上的说明做了所有操作,但这很奇怪,因为我遇到了这种错误。

我正在使用Django 2.2。顺便说一下,这是我的代码。

  

base.html

    <!-- base.html -->

    <!DOCTYPE html>
    <html lang = "en">
    <head>
        <meta charset = "UTF-8">  
        <title>{% block title %}Title{% endblock %}: CAO-SMS Admin</title>

        {% load static %}
        <link rel = "stylesheet" href = "{% static 'fisher_prof/style.css' %}"/>
    </head>

    <body>
        {% block body %}Body{% endblock %}
    </body>
    </html>
  

list.html

    <!-- Displays the whole database (fisher) -->

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

    {% block title %} Fisher's Information {% endblock %}

    {% block body %}
        <br>
        <center>
        <h1>Fisher's Database</h1>
        <table class = "table table-striped table-bordered table-sm">
            <thead class = "thead-dark">
                <tr>
                    <th>ID&nbsp&nbsp</th>
                    <th>Fisher's Last Name</th>
                    <th>Fisher's First Name</th>
                    <th>Fisher's Middle Name</th>
                    <th>Mobile Number</th>
                    <th>Actions</th>
                </tr>
            </thead>

            {% for fisher in fishers %}
            <tr>
                <td>{{fisher.last_name}}</td>
                <td>{{fisher.first_name}}</td>
                <td>{{fisher.mid_name}}</td>
                <td>{{fisher.cell_num}}</td>
            </tr>
            {% endfor %}
        </table>
        <br> <br>
            </center>
    {% endblock %}

然后,当我运行它时,Django告诉我:

  

第41行上的无效块标记:“ endblock”,应为“空”或“ endfor”。您忘记注册或加载此标签了吗?

我的代码有问题吗?我真的需要帮助。

0 个答案:

没有答案