May I ask a secret_key question of python?

as detailed in the title: wtforms, is used in the flask web project, but csrf secret_key is required to report errors all the time

the following is the code: contains multiple file contents, and the file name has been indicated

//models.py

app = Flask(__name__)

app.config["SQLALCHEMY_DATABASE_URI"] = "mysql://lofayo:123456@127.0.0.1:3306/movie"
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True

//key
app.config["SECRET_KEY"] = "af2fad8cfe1f4c5fac4aa5edf6fcc8f3"
app.config["WTF_CSRF_SECRET_KEY"] = "sfsfsfsfs"

db = SQLAlchemy(app)
// forms.py

-sharp coding:utf8
from flask_wtf import Form
from wtforms import StringField, SubmitField
from wtforms.validators import DataRequired

-sharp 
class TagForm(Form):
  name = StringField(
    label="",
    validators=[
          DataRequired("")
      ]
  )
  submit = SubmitField(
    ""
  )
//views.py

from app.admin.forms import TagForm

-sharp 
@admin.route("/tag/add", methods=["GET", "POST"])
def tag_add():
  form  = TagForm()
  return render_template("admin/tag_add.html", form=form)

really do not understand, I hereby ask, those who know please let me know, thank you!

Mar.06,2021

Let me ask you a question. A private demo is built with the same configuration, and it is found that it is normal and there is no "KeyError:'A secret key is required to use CSRF.'". The difference between the previous project and this one is that is it related to the fact that the previous problem project used blueprint,?

Menu