I have a form class like
class StudentForm(FlaskForm):
bool_1= BooleanField('Set bool_1')
bool_2= BooleanField('Set bool_2')
Now in view, I want to get the value of fields like
@app.route('/student', methods=['POST'])
def student():
fields = ['bool_1', 'bool_2']
form = StudentForm()
if request.method == 'POST':
for field in fields:
if form.field.data is True:
print('OK')
return render_template('abc.html', form=form)
But it showing 'StudentForm' object has no attribute 'field'
, I know the field
is a string
. Is there any way to achieve this.