[ad_1]
robin01
January 29, 2023, 10:37pm
#1
Hello All,
I’m trying to assign a value from the session that I created in the login script to set as a default value in the form handling class in this case the department value. As of now the default value of a dropdown menu list is hard coded and I like to assign the value stored in the session.
Error message received:
This typically means that you attempted to use functionality that needed an active HTTP request. Consult the documentation on testing for information about how to avoid this problem.
inputForm1.py
// testDepartmentValue assigned the session variable department
testDepartmentValue = int(session[“isLogged”][‘usrDepartment’])
//Current:
class UserForm(FlaskForm):
departmentSelect = SelectField(‘Department’, coerce=str, choices=[(dpt.dpt_index, dpt.dpt_display) for dpt in dbQueryDepartment], default = 3)
//Objective:
// I like to assign the department value from the session as the default value in the dropdown list menu
class InputForm(FlaskForm):
departmentSelect = SelectField(‘Department’, coerce=str, choices=[(dpt.dpt_index, dpt.dpt_display) for dpt in dbQueryDepartment], default = testDepartmentValue)
..
[ad_2]