search

Home  >  Q&A  >  body text

python - flask表单 如何把提交多行数据在服务端读取出来?

forms

class AddProcessForm(Form):
    process_name = StringField('产品名称')
    step_number = StringField('编号')
    step_name = StringField('编号')
    submit = SubmitField('确定')

views

@manage.route('/admin/process/add', methods=['get', 'post'])
@csrf.exempt
def add_process():
    form = AddProcessForm()
    if form.validate_on_submit():
        print('form',form)
        print(form.process_name)
        print(form.step_name)
        return redirect(url_for('manage.admin'))
    return render_template("/manage/add_process.html", form=form)

页面是可以通过js生成多行step信息,效果如下:



请问我在么在服务器拿到step_name,step_number,
step_name1,step_number1
step_name2,step_number2
step_name3,step_number3
的值??

报错:AttributeError: 'AddProcessForm' object has no attribute 'step_name1'

大家讲道理大家讲道理2781 days ago599

reply all(1)I'll reply

  • PHPz

    PHPz2017-04-18 10:23:37

    This error is reported because the fields such as step_name1 and step_number1 are not defined in your AddProcessForm. When you generate input in JS, the name attributes are called step_name and step_number. Do not add 1 in sequence. Then the backend just accepts this list with the same name and different values.

    reply
    0
  • Cancelreply