jinja2.exceptions.TemplateAssertionError: block 'title' defined twice
{% block content %}
<div class="container">
{% for message in get_flashed_messages() %}
<div class="alert alert-warning">
<button type="button" class="close" data-
dismiss="alert">×</button>
{{ message }}
</div>
{% endfor %}
{% block page_content %}{% endblock %}
</div>
{% endblock %}
##以上是base1.html的内容
======================================
{% extends "base1.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% block page_content %}
<div class="page-header">
<h1>Hello, {% if name %}{{ name }}{% else %}Stranger{% endif %}!</h1>
</div>
{{ wtf.quick_form(form) }}
{% endblock %}
以上是index1.html的内容
=================主程序=======================
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField
from wtforms.validators import DataRequired
from flask import Flask, render_template, session, redirect,url_for
# from collections.abc import Sequence
# import _collections_abc
# from typing import Any, Mapping
app=Flask(__name__)
# bootstrap=Bootstrap(app)
app.config["SECRET_KEY"] = "123456"
class NameForm(FlaskForm):
name = StringField('What is your name?', validators=[DataRequired()])
submit = SubmitField('Submit')
@app.route("/",methods=["GET", "POST"])
def index():
name=None
form = NameForm()
if form.validate_on_submit():
name = form.name.data
form.name.data = ''
return render_template('index1.html', form=form, name=name)
# old_name=session.get("name")
# if old_name is not None and old_name !=form.name.date:
# flash("看看你输入的什么")
# session["name"] = form_name_data
# return redirect(url_for("index"))
# return render_template("index1.html",form = form, name = session.get("name"))
if __name__=="__main__":
app.run(debug=True)
运行后报错,根据错误提示,我查找了代码中的block 'title',并没有被定义两次,然而还是报错,我就删除了代码中唯一的一处block 'title',还是报错。