I have a form that I use to register users. I have another form that I use to login users. These two forms share common properties such as the username and password.
I tried to create a LoginForm that inherits from RegisterForm but I don't know how to remove fields I don't need for login, such as repeat password or the agree to T&Cs checkbox.
How can I do this? These forms inherit from Form not ModelForm.
del form.some_field - either after instantiating the form class or in __init__ (after the super call, and you'd use self instead of form).
https://wtforms.readthedocs.io/en/3.0.x/specific_problems/#removing-fields-per-instance
If LoginForm is truly a subset of RegisterForm, you're probably better off reversing your inheritance.
class LoginForm(Form):
username = ...
password = ...
class ReigsterForm(LoginForm):
confirm_password = ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With