I have created a signup form using wtforms. I am using FormField in it so that I don\'t have to repeat some of the elements of the form again. But whenever I click on the Su
I solved my problem with the following function:
def __init__(self, *args, **kwargs):
kwargs['csrf_enabled'] = False
super(ProfileInfoForm, self).__init__(*args, **kwargs)
I added this function in ProfileInfoForm()
The issue was FormField includes csrf_token field as well as Actual form, i.e., RegistrationForm was also including csrf_token, so there were two csrf_token which were to be verified and only one was getting rendered actually in form. So, I disabled csrf_token in ProfileInfoForm so when FormField rendered it, it had csrf_token = False.
And RegistrationForm does have csrf_token enabled still now so the form is still safe.
My Guess is this does also required to be done in FormField as well.
FYI: This solution might be wrong due to my interpretation of the FormField code. SO please correct me if I am wrong in above solution.