示例代码:
def add_supplier():
form = request.form
if request.method == 'POST':
print(form)
supplier = Supplier(form['supplier_name'],
form['supplier_constract'],
form['supplier_phone'],
form['supplier_address'],
form['supplier_remark'])
try:
db.session.add(supplier)
db.session.commit()
flash('供应商添加成功!', 'success')
except:
db.session.rollback()
flash('输入不合法,请重新输入!', 'danger')
return redirect(url_for('supplier.list_supplier'))
参考文档: