Skip to main content

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 using ACCOUNT_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:
This adds a hidden field to the signup form. Legitimate users won’t see it, but bots may fill it out. If the field contains data, the signup is silently rejected while appearing successful to the bot.
Honeypots work against simple bots but won’t stop sophisticated attacks. Use in combination with other anti-spam measures.

Email Address Management

The EmailAddress Model

django-allauth maintains a separate EmailAddress model with powerful features:
Users have exactly one email address that can be changed.
When changing email:
  1. User adds new email address
  2. Verification email sent to new address
  3. Upon verification, new email replaces old email
  4. 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.
Database Constraints:

Working with Email Addresses

Email Case Sensitivity

Email addresses are always stored in lowercase in django-allauth.
From the source code (models.py:61):
Why lowercase? Email addresses started as case-sensitive but RFCs evolved to discourage this practice. Storing emails as lowercase:
  • Avoids subtle bugs with case-insensitive lookups
  • Improves performance (no need for __iexact queries)
  • Follows modern best practices (RFC 6530)

Password Management

Password Validation

django-allauth respects Django’s AUTH_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:

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

When SESSION_REMEMBER = None, the login form includes a checkbox:
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:
Using the decorator:

User Model Configuration

Custom User Fields

Map allauth to your custom user model fields:

Username Constraints

Custom validators example:

Account Adapter

The adapter is your primary customization point:

Signals

Hook into account events with Django signals:
Sent when a new user completes signup.
Sent when a user successfully logs in.
Sent when a user logs out.
Sent when an email address is verified.
Sent when a new email address is added to an account.
Sent when a user changes their password.

Email Notifications

Send security notifications for account changes:
When enabled, users receive emails when:
  • 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