因此,SignUp 1函数连接到html文件,此部分很好,用户可以提交表单。但是,一旦此表单通过验证,我想调用SignUp2()函数,该函数应将另一个HTML文件与表单连接。但是,一旦用户提交了表单(在SignUp1函数中),我将收到一个错误消息: werkzeug.routing.BuildError:无法为端点'SignUp2'构建URL。
请您告诉我如何从SignUp 1函数调用SignUp2函数。谢谢。
@app.route('/', methods=["GET", "POST"])
def SignUp1():
form = UserForm()
SchoolCode = None
FirstName = None
Postcode = None
Phone = None
ConfirmEmail = None
Password = None
AddLineOne = None
AddLineTwo = None
if form.validate_on_submit():
first_name = form.FirstName.data
last_name = form.LastName.data
postcode = form.Postcode.data
phone = form.Phone.data
email = form.Email.data
password = form.Password.data
add_one = form.AddLineOne.data
add_two = form.AddLineTwo.data
user_id = AddUser(first_name, last_name, postcode, phone, email, password, add_one, add_two)
Parent_id = user_id
SignUp2(Parent_id)
return render_template('SignUp.html', form=form)
def SignUp2(Parent_id):
form = Child1Form()
c1_FirstName = None
c1_LastName = None
c1_Year = None
return render_template('ChildSignUp.html', form=form)
答案 0 :(得分:0)
您还需要给SignUp2提供一条路由,然后您应该重定向,而不是尝试直接调用它。
(注意,所有对None的赋值都是毫无意义的,您在任何地方都不使用任何这些变量。)
@app.route('/', methods=["GET", "POST"])
def SignUp1():
form = UserForm()
...
if form.validate_on_submit():
...
return redirect(url_for('SignUp2', Parent_id=Parent_id))
...
@app.route('/signup2', methods=["GET", "POST"])
def SignUp2(Parent_id):
...