V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
myyou
V2EX  ›  Python

flask 表单验证报错求助!

  •  
  •   myyou · 2016-04-07 14:47:58 +08:00 · 2671 次点击
    这是一个创建于 2951 天前的主题,其中的信息可能已经有所发展或是发生改变。

    flask 使用 form.validate_on_submit()去验证老是通过不了,报错总是{'csrf_token': ['CSRF token missing']} 打印了一下 form.csrf_token.data 发现是有值的,不知道什么原因?

    7 条回复    2016-04-08 09:57:00 +08:00
    z370028987
        1
    z370028987  
       2016-04-07 14:58:18 +08:00
    给的信息太少了。
    strahe
        2
    strahe  
       2016-04-07 15:21:19 +08:00
    配置里有 SECRET_KEY 吗
    cloverstd
        3
    cloverstd  
       2016-04-07 15:38:02 +08:00
    <input name="csrf_token" type="hidden" value="{{ csrf_token() }}">
    myyou
        4
    myyou  
    OP
       2016-04-07 15:38:17 +08:00
    @strahe
    myyou
        5
    myyou  
    OP
       2016-04-07 15:40:24 +08:00
    @cloverstd 这个也加了
    1130335361
        6
    1130335361  
       2016-04-07 21:18:32 +08:00
    @myyou 换成 {{ form.hidden_tag() }} 试试
    myyou
        7
    myyou  
    OP
       2016-04-08 09:57:00 +08:00
    @1130335361 我用的就是{{ form.hidden_tag() }}
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3792 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 10:35 · PVG 18:35 · LAX 03:35 · JFK 06:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.