V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
MrBetterman
V2EX  ›  Flask

请教一下 SelectField 这种字段

  •  
  •   MrBetterman ·
    mr-betterman · Mar 6, 2017 · 3628 views
    This topic created in 3348 days ago, the information mentioned may be changed or developed.
    我的定义是这样的,没有另外键另一个表,能不能在模板上取到我选择的值
    user_type = SelectField(u'用户类型', validators=[Required()] ,choices=[('0', u'房客'),('1', u'房东')])
    1 replies    2017-03-06 23:20:32 +08:00
    codeframe
        1
    codeframe  
       Mar 6, 2017
    在模板里直接用 form.user_type() 会自动帮你生成对应的选择列表
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1594 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 16:30 · PVG 00:30 · LAX 09:30 · JFK 12:30
    ♥ Do have faith in what you're doing.