Skip to main content

SignupView

Handles social account signup when additional information is required from the user.

Class Definition

Attributes

type
The form class to use. Defaults to SignupForm.
str
Template path. Defaults to socialaccount/signup.html or socialaccount/signup.ajax based on ACCOUNT_TEMPLATE_EXTENSION.
SocialLogin
The pending social login instance (set during dispatch).

Methods

dispatch()

Handles the initial request and retrieves the pending social login.
HttpRequest
The Django request object.
HttpResponse
The HTTP response, or redirect to login if no pending signup.
Behavior:
  • Retrieves pending social login from session
  • Redirects to login page if no pending signup found
  • Proceeds with normal dispatch if signup is pending

get_form_class()

Returns the form class to use, checking for custom form in settings.
type
Form class from SOCIALACCOUNT_FORMS['signup'] or default SignupForm.

get_form_kwargs()

Returns keyword arguments for instantiating the form.
dict
Dictionary including the sociallogin parameter.

is_open()

Checks if signup is currently open.
bool
True if signup is open, False otherwise.
Delegates to: adapter.is_open_for_signup(request, sociallogin)

form_valid()

Called when the form is valid.
SignupForm
The validated form instance.
HttpResponse
Redirect response after successful signup.
Process:
  1. Creates user account with form data
  2. Connects social account to user
  3. Logs user in
  4. Redirects to next URL or default location

get_context_data()

Returns context data for rendering the template.
dict
Context dictionary including site and account.

get_authenticated_redirect_url()

Returns URL to redirect authenticated users to.
str
URL to the connections page.

URL Configuration

Template Context

The template receives:
  • form - The signup form
  • site - The current site
  • account - The social account being connected
  • provider - The provider instance
Example template:

Function-based View

The module exports a function-based view instance for use in URL configuration.

LoginCancelledView

Displays a page when the user cancels social authentication.

Class Definition

Attributes

str
Template path. Defaults to socialaccount/login_cancelled.html.

Usage

This view is shown when:
  • User clicks “Cancel” on the provider’s authorization page
  • Provider redirects back with error indicating cancellation

URL Configuration

Template Example

Function-based View


LoginErrorView

Displays an error page when social authentication fails.

Class Definition

Attributes

str
Template path. Defaults to socialaccount/authentication_error.html.

Methods

get()

Handles GET requests and renders the error page with 401 status.
HttpRequest
The Django request object.
HttpResponse
HTTP response with 401 Unauthorized status.

Usage

This view is shown when:
  • Provider returns an error during authentication
  • OAuth flow fails due to invalid state
  • Provider denies access
  • Token exchange fails

URL Configuration

Template Example

Function-based View


ConnectionsView

Manages connected social accounts for authenticated users.

Class Definition

Attributes

str
Template path. Defaults to socialaccount/connections.html.
type
The form class to use. Defaults to DisconnectForm.
str
URL to redirect to after successful disconnection. Defaults to socialaccount_connections.

Methods

get_form_class()

Returns the form class to use, checking for custom form in settings.
type
Form class from SOCIALACCOUNT_FORMS['disconnect'] or default DisconnectForm.

get_form_kwargs()

Returns keyword arguments for instantiating the form.
dict
Dictionary including the request parameter.

form_valid()

Called when the form is valid (account disconnected successfully).
DisconnectForm
The validated form instance.
HttpResponse
Redirect to success URL.

get_ajax_data()

Returns data for AJAX responses.
dict
Dictionary with socialaccounts list containing account data.
Response format:

URL Configuration

Template Context

The template receives:
  • form - The disconnect form
  • socialaccounts - QuerySet of user’s social accounts (via form.accounts)
Example template:

AJAX Usage

Function-based View

View Customization

All views can be extended or replaced:

Extending a View

Adding Custom Views