yakczh
V2EX  ›  问与答

flask 提示 TypeError: Must provide a session-like object as csrf context

  •  
  •   yakczh · Dec 30, 2014 · 2584 views
    This topic created in 4159 days ago, the information mentioned may be changed or developed.
    已经设置了csrf

    from flask.ext.wtf import Form
    from wtforms.fields import TextField, BooleanField,StringField,SubmitField
    from wtforms.validators import Required
    from wtforms.csrf.session import SessionCSRF
    from datetime import timedelta

    class MyBaseForm(Form):
    class Meta:
    csrf = True
    csrf_class = SessionCSRF
    csrf_secret = b'EPj00jpfj8Gx1SjnyLxwBBSQfnQ9DJYe0Ym'
    csrf_time_limit = timedelta(minutes=20)

    class SignupForm(MyBaseForm):

    name = StringField('What is your name?', validators=[Required()])
    submit = SubmitField("Create account")
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1493 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 16:59 · PVG 00:59 · LAX 09:59 · JFK 12:59
    ♥ Do have faith in what you're doing.