Skip to main content

SignupForm

Form for completing social account signup when additional information is required.

Inheritance

Extends allauth.account.forms.BaseSignupForm with social account-specific functionality.

Constructor

SocialLogin
required
The SocialLogin instance for the user being signed up. Must be passed as a keyword argument.
bool
Whether email is required. Defaults to SOCIALACCOUNT_EMAIL_REQUIRED setting.
Example:

Attributes

SocialLogin
The social login instance associated with this signup.

Methods

save()

Saves the user account with data from both the form and the social login.
HttpRequest
The Django request object.
User
The newly created user instance.
Example:
Process:
  1. Calls the adapter’s save_user() method
  2. Invokes custom_signup() hook for additional processing
  3. Returns the saved user

validate_unique_email()

Validates that the email address is unique.
str
The email address to validate.
str
The validated email address.
Raises:
  • ValidationError if the email is already taken, with a provider-specific error message.
Example:

Usage in Views


DisconnectForm

Form for disconnecting a social account from a user’s profile.

Inheritance

Constructor

HttpRequest
required
The Django request object. Must be passed as a keyword argument.
Example:

Fields

ModelChoiceField
Radio select field for choosing which social account to disconnect.Widget: RadioSelect
Required: Yes
Queryset: Social accounts belonging to the current user

Attributes

HttpRequest
The Django request object.
QuerySet
QuerySet of the user’s social accounts.

Methods

clean()

Validates that the selected account can be safely disconnected.
dict
The cleaned form data.
Raises:
  • ValidationError if disconnecting the account would leave the user unable to log in.
Validation checks:
  • User has a usable password, OR
  • User has another connected social account, OR
  • User has a verified email address
Example error:

save()

Disconnects the selected social account from the user. Example:
Process:
  1. Validates the disconnection is safe
  2. Deletes the social account
  3. Sends social_account_removed signal
  4. Sends notification email to user

Usage in Views

Template Usage

Form Customization

Both forms can be customized through settings:

Custom SignupForm Example

Custom DisconnectForm Example