yakczh
V2EX  ›  问与答

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

  •  
  •   yakczh · Dec 30, 2014 · 2608 views
    This topic created in 4177 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   ·   2630 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 15:42 · PVG 23:42 · LAX 08:42 · JFK 11:42
    ♥ Do have faith in what you're doing.