未闭合的标签“块”。寻找其中之一: 端块

use*_*624 2 html python django django-templates

<!--this is my base.html file -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Jumbotron Template for Bootstrap</title>
</head>
<body>
{% block content %}  {% endblock %}
<p>&copy; Company 2014</p>
</body>
</html> 


<!-- this is my signup.html file-->
{% extends "base.html" %}
{% block title %}

    <form method = 'POST' action = ''>{% csrf_token %}

    <label for="your_name">Your name: </label>
    {{form.as_p}}
    <input type = 'submit'>
    </form>
{ % endblock % }
Run Code Online (Sandbox Code Playgroud)

我只是收到错误

“未闭合的标签‘block’。寻找以下之一:endblock”

请帮忙。

ale*_*cxe 11

重要的是不要添加额外的空格并遵循语法。代替:

{ % endblock % }
Run Code Online (Sandbox Code Playgroud)

和:

{% endblock %}
Run Code Online (Sandbox Code Playgroud)

  • 另外,请三重检查并确保您在任何地方都没有缺少 % ,因为您不想像我一样尝试调试它,但没有意识到缺少 % 。 (2认同)