python - flask表单 如何把提交多行数据在服务端读取出来?
大家讲道理
大家讲道理 2017-04-18 10:21:37
0
1
600

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'

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(1)
PHPzhong

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template