推荐学习书目
› 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
ricemo
V2EX  ›  Python

flask 数据库提交一直为 null

  •  
  •   ricemo · Jun 3, 2017 · 2580 views
    This topic created in 3427 days ago, the information mentioned may be changed or developed.
    照着 flask web 那本书敲得代码,之前用户注册一直正常,可以正常生成数据
    后来一直接着写,结果今晚测试的时候,发现数据提交到数据库的时候一直为 null

    代码

    最后把
    user=User(email=form.email.data,username=form.username.data,password=form.password.data)
    分开写成
    user=User()
    user.email=form.email.data
    user.username=form.username.data
    user.password=form.password.data
    就写入成功了
    求解为什么会出现这样的问题
    2 replies  •  2017-06-04 10:26:58 +08:00
    ryd994
        1
    ryd994  
       Jun 4, 2017 via Android
    你的 user class 定义呢?
    initiailizer 写了么?
    ricemo
        2
    ricemo  
    OP
       Jun 4, 2017
    @ryd994 啊啊啊!!!忘了,后来改代码把那个注释掉了,昨晚就一直看一直看,就是不知道出在哪里,一语惊醒,太菜了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5462 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 08:46 · PVG 16:46 · LAX 01:46 · JFK 04:46
    ♥ Do have faith in what you're doing.