Skip to main content

Overview

This guide will help you configure django-allauth in your Django project and get a working authentication system running quickly.
This guide assumes you have already installed django-allauth. If not, check the Installation guide first.

Configuration Steps

Follow these steps to integrate django-allauth into your Django project:
1

Configure Template Context Processors

Add the required context processor to your TEMPLATES setting in settings.py:
settings.py
The django.template.context_processors.request context processor is required by allauth and must be included.
2

Configure Authentication Backends

Add the allauth authentication backend to your settings.py:
settings.py
Keep the ModelBackend to ensure Django admin login continues to work normally.
3

Add Apps to INSTALLED_APPS

Add the required allauth apps to INSTALLED_APPS in your settings.py:
For basic account functionality without social authentication:
settings.py
The django.contrib.sites framework is required. Make sure to set SITE_ID = 1 in your settings.
4

Add Account Middleware

Add the account middleware to your MIDDLEWARE setting:
settings.py
The AccountMiddleware must be placed after AuthenticationMiddleware.
5

Configure URL Patterns

Add allauth URLs to your project’s urls.py:
urls.py
You can use any URL prefix you prefer instead of accounts/. Common alternatives include auth/ or user/.
6

Run Migrations

Create the necessary database tables:
This will create tables for:
  • User accounts
  • Email addresses
  • Email confirmations
  • Social accounts (if enabled)
  • MFA tokens (if enabled)
7

Configure Basic Settings

Add essential allauth configuration to your settings.py:
settings.py

Complete Configuration Example

Here’s a complete example of a minimal settings.py configuration:

Social Provider Configuration

To enable social authentication providers, you need to configure them in your settings:
Alternatively, you can configure social apps through the Django admin interface instead of settings.

Testing Your Setup

Start the development server and test your authentication system:
Visit the following URLs to verify everything is working:

Login

http://localhost:8000/accounts/login/

Signup

http://localhost:8000/accounts/signup/

Password Reset

http://localhost:8000/accounts/password/reset/

Admin

http://localhost:8000/admin/

Common Configuration Options

Customize django-allauth behavior with these popular settings:
settings.py
settings.py
settings.py
settings.py
settings.py

Important Security Considerations

Session Engine Compatibilitydjango-allauth is NOT compatible with SESSION_ENGINE set to "django.contrib.sessions.backends.signed_cookies".Signed cookies are signed but not encrypted, whereas allauth stores secrets (e.g. verification codes) in the session.
For production environments, always:
  • Use HTTPS
  • Set DEBUG = False
  • Configure proper email backend (not console)
  • Enable rate limiting
  • Use strong SECRET_KEY
  • Enable account enumeration prevention

Creating a Superuser

Create an admin user to access the Django admin:
You can now:
  1. Access the admin at http://localhost:8000/admin/
  2. Configure social apps
  3. Manage user accounts
  4. View email addresses and verifications

URL Patterns Provided

Once configured, django-allauth provides these URL patterns:
You don’t need to include django.contrib.auth.urls when using allauth, as it provides all necessary authentication URLs.

Example Project

The django-allauth repository includes a fully functional example project:
Visit the live demo at: https://django.demo.allauth.org

Next Steps

Account Configuration

Explore all available configuration options

Social Providers

Set up social authentication providers

Templates

Customize the look and feel

Signals

Hook into authentication events