I have a student registration form that immediately after registering a student I want to use those details in another form, a payments form to enter that student's payment status but my code keeps returning none like student is not available, I am doing something wrong here please assist me figure it out or show me a better way of doing achieving the same logic:
CODE:
def registration():
form=SQLFORM(db.store_registration)
if form.process().accepted:
response.flash=T('Details Registered')
student_name = "{form.vars.first_name} {form.vars.last_name}"
# Redirect to payments view with student's name as parameter
redirect(URL('default', 'payments', vars={'student_name': student_name}))
return locals()
def payments():
student_name = request.vars.student_name
# Loading student's information from the database
student = db(db.store_registration.first_name + ' ' + db.store_registration.last_name == student_name).select().first()
if student is None:
raise HTTP(404, "Student not found")
form.vars.student = student.id # Set the student reference in the payment form
form = SQLFORM(db.payments)
if form.process().accepted:
response.flash = T('Payment details submitted')
return locals()
Regards