| 1 |
Forms |
| 2 |
===== |
| 3 |
|
| 4 |
Login |
| 5 |
***** |
| 6 |
|
| 7 |
*Path*: |
| 8 |
``allauth.account.forms.LoginForm`` |
| 9 |
*Used on*: |
| 10 |
`account_login <views.html#login-account-login>`__ view. |
| 11 |
|
| 12 |
Example override:: |
| 13 |
|
| 14 |
from allauth.account.forms import LoginForm |
| 15 |
class MyCustomLoginForm(LoginForm): |
| 16 |
|
| 17 |
def login(self, *args, **kwargs): |
| 18 |
|
| 19 |
# Add your own processing here. |
| 20 |
|
| 21 |
# You must return the original result. |
| 22 |
return super().login(*args, **kwargs) |
| 23 |
|
| 24 |
You have access to the following: |
| 25 |
|
| 26 |
- ``self.user`` is the User object that is logging in. |
| 27 |
|
| 28 |
``settings.py``:: |
| 29 |
|
| 30 |
ACCOUNT_FORMS = {'login': 'mysite.forms.MyCustomLoginForm'} |
| 31 |
|
| 32 |
By default, the password field renders a "Forgot your password?" link as the |
| 33 |
help text. By providing a ``"account/password_reset_help_text.html"`` template |
| 34 |
you can customize that text. |
| 35 |
|
| 36 |
|
| 37 |
Signup |
| 38 |
****** |
| 39 |
|
| 40 |
*Path*: |
| 41 |
``allauth.account.forms.SignupForm`` |
| 42 |
*Used on*: |
| 43 |
`account_signup <views.html#signup-account-signup>`__ view. |
| 44 |
|
| 45 |
Example override:: |
| 46 |
|
| 47 |
from allauth.account.forms import SignupForm |
| 48 |
class MyCustomSignupForm(SignupForm): |
| 49 |
|
| 50 |
def save(self, request): |
| 51 |
|
| 52 |
# Ensure you call the parent class's save. |
| 53 |
# .save() returns a User object. |
| 54 |
user = super().save(request) |
| 55 |
|
| 56 |
# Add your own processing here. |
| 57 |
|
| 58 |
# You must return the original result. |
| 59 |
return user |
| 60 |
|
| 61 |
``settings.py``:: |
| 62 |
|
| 63 |
ACCOUNT_FORMS = {'signup': 'mysite.forms.MyCustomSignupForm'} |
| 64 |
|
| 65 |
|
| 66 |
Add Email |
| 67 |
********* |
| 68 |
|
| 69 |
*Path*: |
| 70 |
``allauth.account.forms.AddEmailForm`` |
| 71 |
*Used on*: |
| 72 |
`account_email <views.html#emails-management-account-email>`__ view. |
| 73 |
|
| 74 |
Example override:: |
| 75 |
|
| 76 |
from allauth.account.forms import AddEmailForm |
| 77 |
class MyCustomAddEmailForm(AddEmailForm): |
| 78 |
|
| 79 |
def save(self, request): |
| 80 |
|
| 81 |
# Ensure you call the parent class's save. |
| 82 |
# .save() returns an allauth.account.models.EmailAddress object. |
| 83 |
email_address_obj = super().save(request) |
| 84 |
|
| 85 |
# Add your own processing here. |
| 86 |
|
| 87 |
# You must return the original result. |
| 88 |
return email_address_obj |
| 89 |
|
| 90 |
You have access to the following: |
| 91 |
|
| 92 |
- ``self.user`` is the User object that is logged in. |
| 93 |
|
| 94 |
``settings.py``:: |
| 95 |
|
| 96 |
ACCOUNT_FORMS = {'add_email': 'mysite.forms.MyCustomAddEmailForm'} |
| 97 |
|
| 98 |
|
| 99 |
Change Password |
| 100 |
*************** |
| 101 |
|
| 102 |
*Path*: |
| 103 |
``allauth.account.forms.ChangePasswordForm`` |
| 104 |
*Used on*: |
| 105 |
`account_change_password <views.html#password-management>`__ view. |
| 106 |
|
| 107 |
Example override:: |
| 108 |
|
| 109 |
from allauth.account.forms import ChangePasswordForm |
| 110 |
class MyCustomChangePasswordForm(ChangePasswordForm): |
| 111 |
|
| 112 |
def save(self): |
| 113 |
|
| 114 |
# Ensure you call the parent class's save. |
| 115 |
# .save() does not return anything |
| 116 |
super().save() |
| 117 |
|
| 118 |
# Add your own processing here. |
| 119 |
|
| 120 |
You have access to the following: |
| 121 |
|
| 122 |
- ``self.user`` is the User object that is logged in. |
| 123 |
|
| 124 |
``settings.py``:: |
| 125 |
|
| 126 |
ACCOUNT_FORMS = {'change_password': 'mysite.forms.MyCustomChangePasswordForm'} |
| 127 |
|
| 128 |
By default, the current password field renders a "Forgot your password?" link as the |
| 129 |
help text. By providing a ``"account/password_reset_help_text.html"`` template |
| 130 |
you can customize that text. |
| 131 |
|
| 132 |
|
| 133 |
Set Password |
| 134 |
************ |
| 135 |
|
| 136 |
*Path*: |
| 137 |
``allauth.account.forms.SetPasswordForm`` |
| 138 |
*Used on*: |
| 139 |
`account_set_password <views.html#password-management>`__ view. |
| 140 |
|
| 141 |
Example override:: |
| 142 |
|
| 143 |
from allauth.account.forms import SetPasswordForm |
| 144 |
class MyCustomSetPasswordForm(SetPasswordForm): |
| 145 |
|
| 146 |
def save(self): |
| 147 |
|
| 148 |
# Ensure you call the parent class's save. |
| 149 |
# .save() does not return anything |
| 150 |
super().save() |
| 151 |
|
| 152 |
# Add your own processing here. |
| 153 |
|
| 154 |
You have access to the following: |
| 155 |
|
| 156 |
- ``self.user`` is the User object that is logged in. |
| 157 |
|
| 158 |
``settings.py``:: |
| 159 |
|
| 160 |
ACCOUNT_FORMS = {'set_password': 'mysite.forms.MyCustomSetPasswordForm'} |
| 161 |
|
| 162 |
Reset Password |
| 163 |
************** |
| 164 |
|
| 165 |
*Path*: |
| 166 |
``allauth.account.forms.ResetPasswordForm`` |
| 167 |
*Used on*: |
| 168 |
`account_reset_password <views.html#password-reset-account-reset-password>`__ view. |
| 169 |
|
| 170 |
Example override:: |
| 171 |
|
| 172 |
from allauth.account.forms import ResetPasswordForm |
| 173 |
class MyCustomResetPasswordForm(ResetPasswordForm): |
| 174 |
|
| 175 |
def save(self, request): |
| 176 |
|
| 177 |
# Ensure you call the parent class's save. |
| 178 |
# .save() returns a string containing the email address supplied |
| 179 |
email_address = super().save(request) |
| 180 |
|
| 181 |
# Add your own processing here. |
| 182 |
|
| 183 |
# Ensure you return the original result |
| 184 |
return email_address |
| 185 |
|
| 186 |
You have access to the following: |
| 187 |
|
| 188 |
- ``self.users`` is a list of all possible User objects with matching email address. |
| 189 |
|
| 190 |
``settings.py``:: |
| 191 |
|
| 192 |
ACCOUNT_FORMS = {'reset_password': 'mysite.forms.MyCustomResetPasswordForm'} |
| 193 |
|
| 194 |
|
| 195 |
Reset Password From Key |
| 196 |
*********************** |
| 197 |
|
| 198 |
*Path*: |
| 199 |
``allauth.account.forms.ResetPasswordKeyForm`` |
| 200 |
*Used on*: |
| 201 |
`account_reset_password <views.html#password-reset-account-reset-password>`__ view. |
| 202 |
|
| 203 |
Example override:: |
| 204 |
|
| 205 |
from allauth.account.forms import ResetPasswordKeyForm |
| 206 |
class MyCustomResetPasswordKeyForm(ResetPasswordKeyForm): |
| 207 |
|
| 208 |
def save(self): |
| 209 |
|
| 210 |
# Add your own processing here. |
| 211 |
|
| 212 |
# Ensure you call the parent class's save. |
| 213 |
# .save() does not return anything |
| 214 |
super().save() |
| 215 |
|
| 216 |
You have access to the following: |
| 217 |
|
| 218 |
- ``self.user`` is the User object. |
| 219 |
|
| 220 |
``settings.py``:: |
| 221 |
|
| 222 |
ACCOUNT_FORMS = {'reset_password_from_key': 'mysite.forms.MyCustomResetPasswordKeyForm'} |