qq_36474164
勿扰tel
2019-03-08 19:23

wtforms FieldList 报错,求解?

10
  • flask
class OptionForm(Form):
    order_num= IntegerField(validators=[DataRequired()])
    opt_cont=StringField(validators=[DataRequired()])


class QuestionForm(Form):
    genre=IntegerField(validators=[DataRequired()])
    questiontext=StringField(validators=[DataRequired()])
    answer=StringField(validators=[DataRequired()])
    paper_id=IntegerField(validators=[DataRequired()])

    option=FieldList(FormField(OptionForm))

错误提示:TypeError: init() got an unexpected keyword argument 'formdata'
option=FieldList(StringField())
就不会报错,还能拿到值。

{
  "answer": "1",
  "genre": 1,
  "option": [
    {
      "opt_cont": "我是一个选项",
      "order_num": 1
    }
  ],
  "paper_id": 1,
  "questiontext": "今天吃什么?"
}

type(option)=list
type(option[0])=dict

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐

换一换