Skip to main content
django-allauth provides extensive form customization options. You can override built-in forms to add custom fields, modify validation logic, or change form behavior.

Overview

Forms in django-allauth handle:
  • User signup and login
  • Password management (change, reset, set)
  • Email address management
  • Login codes and verification codes
  • Social account connections
All forms can be customized by overriding them in your settings.

Configuration

Override forms using the ACCOUNT_FORMS setting:
Source: allauth/account/app_settings.py:464

Login Form

Default Form

Path: allauth.account.forms.LoginForm
Used on: Login view (account_login)

Customization

Available Attributes

  • self.user - The User object that is logging in

Password Help Text

Customize the “Forgot your password?” link by providing a template:

Signup Form

Default Form

Path: allauth.account.forms.SignupForm
Used on: Signup view (account_signup)

Basic Customization

Advanced Example with Validation

Signup Form Class

Alternatively, use ACCOUNT_SIGNUP_FORM_CLASS to specify just additional fields:
Source: allauth/account/app_settings.py:314

Add Email Form

Default Form

Path: allauth.account.forms.AddEmailForm
Used on: Email management view (account_email)

Customization

Available Attributes

  • self.user - The User object that is logged in

Change Password Form

Default Form

Path: allauth.account.forms.ChangePasswordForm
Used on: Change password view (account_change_password)

Customization

Available Attributes

  • self.user - The User object that is logged in

Set Password Form

Default Form

Path: allauth.account.forms.SetPasswordForm
Used on: Set password view (account_set_password)
Used when a user doesn’t have a usable password (e.g., signed up via social auth).

Customization

Available Attributes

  • self.user - The User object that is logged in

Reset Password Form

Default Form

Path: allauth.account.forms.ResetPasswordForm
Used on: Password reset view (account_reset_password)

Customization

Available Attributes

  • self.users - List of all possible User objects with matching email address

Reset Password From Key Form

Default Form

Path: allauth.account.forms.ResetPasswordKeyForm
Used on: Password reset confirmation view

Customization

Available Attributes

  • self.user - The User object

Social Account Forms

Customize social account forms using SOCIALACCOUNT_FORMS:
Source: allauth/socialaccount/app_settings.py:130

Social Signup Form

Form Field Customization

Field Configuration

Control which fields appear in the signup form:
Source: allauth/account/app_settings.py:328

Widget Customization

Customize form widgets:

Complete Example

Here’s a comprehensive example with multiple customized forms:

Validation Helpers

Using Django Validators

Custom Validation Methods

Best Practices

  1. Always call super() - Ensure parent methods are called to maintain functionality
  2. Return values - Form save methods must return the expected object
  3. Log changes - Log important events like password changes
  4. Validate early - Use clean_* methods for field-specific validation
  5. Use error_messages - Provide user-friendly error messages
  6. Style consistently - Apply consistent CSS classes and styling
  7. Test thoroughly - Test all validation paths and edge cases