V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
MrBetterman
V2EX  ›  Flask

请教一下 SelectField 这种字段

  •  
  •   MrBetterman ·
    mr-betterman · 2017-03-06 22:24:58 +08:00 · 2627 次点击
    这是一个创建于 2598 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我的定义是这样的,没有另外键另一个表,能不能在模板上取到我选择的值
    user_type = SelectField(u'用户类型', validators=[Required()] ,choices=[('0', u'房客'),('1', u'房东')])
    1 条回复    2017-03-06 23:20:32 +08:00
    codeframe
        1
    codeframe  
       2017-03-06 23:20:32 +08:00
    在模板里直接用 form.user_type() 会自动帮你生成对应的选择列表
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   967 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 21:26 · PVG 05:26 · LAX 14:26 · JFK 17:26
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.