我的flask应用程序中有两个应用程序路由,第一个收集客户数据,然后将其提交到数据库。 第二个收集地址数据,然后将其提交到数据库
@app.route ('/register', methods=['GET', 'POST'])
def register():
form = RegistrationForm()
if form.validate_on_submit():
customer_details = Customer(first_name=form.first_name.data, last_name=form.last_name.data, email_address=form.email_address.data)
db.session.add(customer_details)
db.session.commit()
return redirect(url_for('register_address'))
return render_template('register.html', title='Personal Details', form=form)
@app.route('/register_address', methods=['GET', 'POST'])
def register_address():
form = AddressForm()
if form.validate_on_submit():
address_details = Address(house_no=form.house_no.data, first_line=form.first_line.data, second_line=form.second_line.data, postcode=form.postcode.data)
db.session.add(address_details)
db.session.commit()
flash(f'Account created successfully')
return redirect(url_for('home'))
return render_template('register_address.html', title='Address Details', form=form)
在register_address函数中,我想提交所有数据库操作,但我不能100%确定如何完成。 任何关于这方面的建议都是个好主意
干杯
目前没有回答
相关问题 更多 >
编程相关推荐