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:Configure Template Context Processors
Add the required context processor to your
TEMPLATES setting in settings.py:settings.py
Configure Authentication Backends
Add the allauth authentication backend to your
settings.py:settings.py
Add Apps to INSTALLED_APPS
Add the required allauth apps to
INSTALLED_APPS in your settings.py:- Basic Setup
- With MFA
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.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)
Complete Configuration Example
Here’s a complete example of a minimalsettings.py configuration:
Social Provider Configuration
To enable social authentication providers, you need to configure them in your settings:Testing Your Setup
Start the development server and test your authentication system: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:Login Method Configuration
Login Method Configuration
settings.py
Email Verification Options
Email Verification Options
settings.py
Signup Field Configuration
Signup Field Configuration
settings.py
Advanced Features
Advanced Features
settings.py
Security Settings
Security Settings
settings.py
Important Security Considerations
Creating a Superuser
Create an admin user to access the Django admin:- Access the admin at
http://localhost:8000/admin/ - Configure social apps
- Manage user accounts
- View email addresses and verifications
URL Patterns Provided
Once configured, django-allauth provides these URL patterns:| URL Pattern | Description |
|---|---|
/accounts/login/ | User login page |
/accounts/signup/ | User registration page |
/accounts/logout/ | Logout endpoint |
/accounts/password/reset/ | Password reset request |
/accounts/password/change/ | Change password (authenticated) |
/accounts/email/ | Manage email addresses |
/accounts/confirm-email/<key>/ | Email confirmation |
/accounts/social/connections/ | Manage social connections |
/accounts/social/login/<provider>/ | Social login initiation |
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: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
