| 1 |
Forms |
| 2 |
===== |
| 3 |
|
| 4 |
Signup |
| 5 |
****** |
| 6 |
|
| 7 |
*Path*: |
| 8 |
``allauth.socialaccount.forms.SignupForm`` |
| 9 |
|
| 10 |
*Used on*: |
| 11 |
``socialaccount_signup`` view used when a user initially signs up |
| 12 |
with a social account and needs to create an account. |
| 13 |
|
| 14 |
Example override:: |
| 15 |
|
| 16 |
from allauth.socialaccount.forms import SignupForm |
| 17 |
class MyCustomSocialSignupForm(SignupForm): |
| 18 |
|
| 19 |
def save(self, request): |
| 20 |
|
| 21 |
# Ensure you call the parent class's save. |
| 22 |
# .save() returns a User object. |
| 23 |
user = super().save(request) |
| 24 |
|
| 25 |
# Add your own processing here. |
| 26 |
|
| 27 |
# You must return the original result. |
| 28 |
return user |
| 29 |
|
| 30 |
You have access to the following: |
| 31 |
|
| 32 |
- ``self.socialaccount`` |
| 33 |
|
| 34 |
``settings.py``:: |
| 35 |
|
| 36 |
SOCIALACCOUNT_FORMS = {'signup': 'mysite.forms.MyCustomSocialSignupForm'} |
| 37 |
|
| 38 |
Disconnect |
| 39 |
********** |
| 40 |
|
| 41 |
*Path*: |
| 42 |
``allauth.socialaccount.forms.DisconnectForm`` |
| 43 |
*Used on*: |
| 44 |
``socialaccount_connections`` view, used when removing a social account. |
| 45 |
|
| 46 |
Example override:: |
| 47 |
|
| 48 |
from allauth.socialaccount.forms import DisconnectForm |
| 49 |
class MyCustomSocialDisconnectForm(DisconnectForm): |
| 50 |
|
| 51 |
def save(self): |
| 52 |
|
| 53 |
# Add your own processing here if you do need access to the |
| 54 |
# socialaccount being deleted. |
| 55 |
|
| 56 |
# Ensure you call the parent class's save. |
| 57 |
# .save() does not return anything |
| 58 |
super().save() |
| 59 |
|
| 60 |
# Add your own processing here if you don't need access to the |
| 61 |
# socialaccount being deleted. |
| 62 |
|
| 63 |
You have access to the following: |
| 64 |
|
| 65 |
- ``self.request`` is the request object |
| 66 |
- ``self.accounts`` is a list containing all of the user's SocialAccount objects. |
| 67 |
- ``self.cleaned_data['account']`` contains the socialaccount being deleted. ``.save()`` |
| 68 |
issues the delete. So if you need access to the socialaccount beforehand, move your |
| 69 |
code before ``.save()``. |
| 70 |
|
| 71 |
``settings.py``:: |
| 72 |
|
| 73 |
SOCIALACCOUNT_FORMS = {'disconnect': 'mysite.forms.MyCustomSocialDisconnectForm'} |