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
jmania
V2EX  ›  Python

flask-wtf 中如何让 selectField 读取的数据中选中默认项?

  •  
  •   jmania · 2013-08-15 17:26:12 +08:00 · 9787 次点击
    这是一个创建于 3915 天前的主题,其中的信息可能已经有所发展或是发生改变。
    6 条回复    1970-01-01 08:00:00 +08:00
    jmania
        1
    jmania  
    OP
       2013-08-15 17:50:46 +08:00
    没人知道咩?
    ry_wang
        2
    ry_wang  
       2013-08-15 17:53:24 +08:00
    如果是CreateForm场景,在Form定义处设置field的default值为True。
    如果是EditForm场景,设定传参field.data为True。
    jmania
        3
    jmania  
    OP
       2013-08-15 17:59:17 +08:00
    是EditForm场景,能不能详细说下?网上都搜不到资料
    Perry
        4
    Perry  
       2013-08-15 18:20:21 +08:00
    在render template之前使用formname.fieldname.data = 默认的选项
    jmania
        5
    jmania  
    OP
       2013-08-15 18:32:04 +08:00
    @Perry 非常感谢
    lepture
        6
    lepture  
       2013-08-16 13:26:12 +08:00
    提醒一下,Flask-WTF 发布 0.9.0 了。

    http://python-china.org/topic/647
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1702 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 00:23 · PVG 08:23 · LAX 17:23 · JFK 20:23
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.