Overview
django-allauth provides comprehensive account management capabilities that go far beyond simple login/logout. It handles user registration, multiple email addresses, password changes, and complex email verification workflows.The
allauth.account app is the core module responsible for managing regular (non-social) user accounts.User Registration (Signup)
Signup Fields Configuration
Control which fields appear in your signup form usingACCOUNT_SIGNUP_FIELDS:
Fields marked with
* (e.g., 'email*') are required. Fields without * are optional.Custom Signup Forms
Add custom fields to the signup process:Honeypot Field for Spam Prevention
Protect against naive spam bots with a honeypot field:Email Address Management
The EmailAddress Model
django-allauth maintains a separateEmailAddress model with powerful features:
- Single Email Mode
- Multiple Email Mode
Users have exactly one email address that can be changed.When changing email:
- User adds new email address
- Verification email sent to new address
- Upon verification, new email replaces old email
- Old email is automatically removed
Email Uniqueness
Control whether email addresses must be unique across all users:When
ACCOUNT_UNIQUE_EMAIL = True, only one user can have a verified email address. This prevents account confusion and is recommended for most applications.Working with Email Addresses
Email Case Sensitivity
From the source code (models.py:61):
- Avoids subtle bugs with case-insensitive lookups
- Improves performance (no need for
__iexactqueries) - Follows modern best practices (RFC 6530)
Password Management
Password Validation
django-allauth respects Django’sAUTH_PASSWORD_VALIDATORS:
If no validators are configured, allauth falls back to
ACCOUNT_PASSWORD_MIN_LENGTH (default: 6).Change Password
Authenticated users can change their password:- View
- Template
- Adapter Hook
Password Reset
Password reset flow with enumeration prevention: Configuration:Password Reset by Code
Alternative to link-based password reset using one-time codes:1
User Requests Reset
User enters email address in password reset form
2
Code Sent
6-digit code sent to user’s email (e.g., “123456”)
3
User Enters Code
User enters code within timeout period (default: 3 minutes)
4
Password Changed
After code verification, user sets new password
Session Management
Remember Me Functionality
SESSION_REMEMBER = None, the login form includes a checkbox:
Session Cookie Age
ACCOUNT_SESSION_COOKIE_AGE is deprecated. Use Django’s SESSION_COOKIE_AGE directly.Reauthentication
For sensitive operations, require users to re-enter credentials even if already logged in:User Model Configuration
Custom User Fields
Map allauth to your custom user model fields:Username Constraints
Account Adapter
The adapter is your primary customization point:Signals
Hook into account events with Django signals:user_signed_up
user_signed_up
Sent when a new user completes signup.
user_logged_in
user_logged_in
Sent when a user successfully logs in.
user_logged_out
user_logged_out
Sent when a user logs out.
email_confirmed
email_confirmed
Sent when an email address is verified.
email_added
email_added
Sent when a new email address is added to an account.
password_changed
password_changed
Sent when a user changes their password.
Email Notifications
Send security notifications for account changes:- Password is changed
- Email address is added/removed
- Login from new device (with user agent/IP info)
Next Steps
Authentication Flows
Learn about login, signup, and password reset flows
Email Verification
Configure email verification strategies
