'How do I customize the ResetPasswordForm in Django-AllAuth

I'm running into a couple of issues. Firstly, from the configuration section of the docs...

ACCOUNT_FORMS (={})
Used to override forms, for example: {‘login’: ‘myapp.forms.LoginForm’}

How do I know what to put here? I know it needs to be a (key, value) pair like 'password_reset_form':'myapp.forms.MyPasswordResetForm' but how do I know the correct key to use?

Secondly, in my forms.py I tried to extend the ResetPasswordForm like

from allauth.account.forms import ResetPasswordForm

class MyResetPasswordForm(ResetPasswordForm):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # Override the email widget
        self.fields['email'].widget = forms.TextInput(attrs={'class':'form-control', 'type':'email', 'required':'required', 'placeholder':'Email'})

but this keeps giving me the error Error importing form class accounts.forms: "cannot import name 'ResetPasswordForm'"

Any advice advice or direction on this would be appreciated.



Solution 1:[1]

Here is all the forms you can customize:

ACCOUNT_FORMS = {
    'login': 'allauth.account.forms.LoginForm',
    'signup': 'allauth.account.forms.SignupForm',
    'add_email': 'allauth.account.forms.AddEmailForm',
    'change_password': 'allauth.account.forms.ChangePasswordForm',
    'set_password': 'allauth.account.forms.SetPasswordForm',
    'reset_password': 'allauth.account.forms.ResetPasswordForm',
    'reset_password_from_key': 
    'allauth.account.forms.ResetPasswordKeyForm',
    'disconnect': 'allauth.socialaccount.forms.DisconnectForm',
}

also, you can check the docs to see for yourself.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 erfan ghorbani