Not a Valid Choice for Dynamic Select Field WTFORMS

后端 未结 2 491
梦毁少年i
梦毁少年i 2020-12-02 14:26

I currently am creating a dynamic select field using WTFORMS, however it never submits and fails the validation with the following error.

Not a valid choice
         


        
2条回答
  •  借酒劲吻你
    2020-12-02 15:07

    Here is how you can solve it without QuerySelectField.

    Here is how I did:

    years = [(str(y), y) for y in reversed(range(1950, 2013))]
    years.insert(0, ('','year'))
    year = wt.SelectField(choices=years)
    

提交回复
热议问题