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
Configuration
Override forms using theACCOUNT_FORMS setting:
allauth/account/app_settings.py:464
Login Form
Default Form
Path:allauth.account.forms.LoginFormUsed 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.SignupFormUsed on: Signup view (
account_signup)
Basic Customization
Advanced Example with Validation
Signup Form Class
Alternatively, useACCOUNT_SIGNUP_FORM_CLASS to specify just additional fields:
allauth/account/app_settings.py:314
Add Email Form
Default Form
Path:allauth.account.forms.AddEmailFormUsed 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.ChangePasswordFormUsed 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.SetPasswordFormUsed 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.ResetPasswordFormUsed 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.ResetPasswordKeyFormUsed on: Password reset confirmation view
Customization
Available Attributes
self.user- The User object
Social Account Forms
Customize social account forms usingSOCIALACCOUNT_FORMS:
allauth/socialaccount/app_settings.py:130
Social Signup Form
Form Field Customization
Field Configuration
Control which fields appear in the signup form: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
- Always call super() - Ensure parent methods are called to maintain functionality
- Return values - Form save methods must return the expected object
- Log changes - Log important events like password changes
- Validate early - Use
clean_*methods for field-specific validation - Use error_messages - Provide user-friendly error messages
- Style consistently - Apply consistent CSS classes and styling
- Test thoroughly - Test all validation paths and edge cases
