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
0xvincebye
V2EX  ›  Python

flask 数据库提交一直为 null

  •  
  •   0xvincebye · 2017-06-03 23:21:44 +08:00 · 2026 次点击
    这是一个创建于 2489 天前的主题,其中的信息可能已经有所发展或是发生改变。
    照着 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 条回复    2017-06-04 10:26:58 +08:00
    ryd994
        1
    ryd994  
       2017-06-04 10:17:59 +08:00 via Android
    你的 user class 定义呢?
    initiailizer 写了么?
    0xvincebye
        2
    0xvincebye  
    OP
       2017-06-04 10:26:58 +08:00
    @ryd994 啊啊啊!!!忘了,后来改代码把那个注释掉了,昨晚就一直看一直看,就是不知道出在哪里,一语惊醒,太菜了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5241 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 09:38 · PVG 17:38 · LAX 02:38 · JFK 05:38
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.