I’m using Flask with Flask-WTForms and am writing an admin page where it’s possible to update values for a user – including the password.
I’m using the same form page that I use for registration, but since it’s not requisite that the password be updated, I don’t want to require it. What is the right way to do this with Flask-WTForms?
I’ve got my UserForm in forms.py and I was thinking of making a custom validator and have a file-level require_password option that would override the default check. I’m fairly new to WTForms, and somewhat new to Flask.
This solution seems to do what I want:
In
forms.py,Then inside my flask endpoint I can call:
That seems to do what I wanted – keep all the other validation (e.g. confirmation), while ignoring anything if there is no password present.