V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
yakczh
V2EX  ›  问与答

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

  •  
  •   yakczh · Dec 30, 2014 · 2545 views
    This topic created in 4135 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   ·   823 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 20:50 · PVG 04:50 · LAX 13:50 · JFK 16:50
    ♥ Do have faith in what you're doing.