{"id":2473,"library":"django-allauth","title":"django-allauth","description":"django-allauth is an integrated set of Django applications that provides comprehensive solutions for authentication, registration, account management, and third-party (social) account authentication. It is actively maintained with frequent releases, often aligning with new Django and Python versions. It aims to offer a unified approach to both local and social authentication flows.","status":"active","version":"65.15.1","language":"en","source_language":"en","source_url":"https://codeberg.org/allauth/django-allauth","tags":["django","authentication","social-login","registration","account-management","multi-factor-authentication"],"install":[{"cmd":"pip install django-allauth","lang":"bash","label":"Basic installation (without social accounts or headless API)"},{"cmd":"pip install \"django-allauth[socialaccount]\"","lang":"bash","label":"With social account providers (most common)"},{"cmd":"pip install \"django-allauth[headless]\"","lang":"bash","label":"With headless API support (e.g., for JWT)"}],"dependencies":[{"reason":"Core framework dependency; django-allauth versions are tied to Django versions.","package":"Django","optional":false}],"imports":[{"note":"Primary application entry for core functionality.","symbol":"allauth","correct":"INSTALLED_APPS = ['allauth', ...]"},{"note":"Required for regular (username/email/password) account management.","symbol":"allauth.account","correct":"INSTALLED_APPS = ['allauth.account', ...]"},{"note":"Required for social login functionality.","symbol":"allauth.socialaccount","correct":"INSTALLED_APPS = ['allauth.socialaccount', ...]"},{"note":"Includes all necessary authentication, registration, and account management URLs.","symbol":"allauth.urls","correct":"path('accounts/', include('allauth.urls'))"},{"note":"While ModelBackend is often kept for Django admin, allauth requires its own backend for proper functionality, especially for email authentication or social logins. Both should be in AUTHENTICATION_BACKENDS.","wrong":"from django.contrib.auth.backends import ModelBackend","symbol":"AuthenticationBackend","correct":"from allauth.account.auth_backends import AuthenticationBackend"},{"note":"Used for customizing various aspects of account management behavior.","symbol":"DefaultAccountAdapter","correct":"from allauth.account.adapter import DefaultAccountAdapter"}],"quickstart":{"code":"import os\n\n# settings.py\n# Add to INSTALLED_APPS (order matters, 'django.contrib.sites' and 'allauth' apps come after Django's built-in apps)\nINSTALLED_APPS = [\n    # ... django defaults\n    'django.contrib.sites',\n    'allauth',\n    'allauth.account',\n    'allauth.socialaccount', # Optional: if using social logins\n    # ... add specific social providers here, e.g., 'allauth.socialaccount.providers.google',\n]\n\nSITE_ID = 1 # Must be set to 1 for allauth to function correctly\n\nAUTHENTICATION_BACKENDS = [\n    'django.contrib.auth.backends.ModelBackend', # Required for Django admin\n    'allauth.account.auth_backends.AuthenticationBackend', # allauth specific backend\n]\n\n# Required context processor for allauth templates\nTEMPLATES = [\n    {\n        'BACKEND': 'django.template.backends.django.DjangoTemplates',\n        'DIRS': [os.path.join(BASE_DIR, 'templates')],\n        'APP_DIRS': True,\n        'OPTIONS': {\n            'context_processors': [\n                'django.template.context_processors.debug',\n                'django.template.context_processors.request',\n                'django.contrib.auth.context_processors.auth',\n                'django.contrib.messages.context_processors.messages',\n            ],\n        },\n    },\n]\n\n# allauth specific settings\nACCOUNT_EMAIL_REQUIRED = True\nACCOUNT_USERNAME_REQUIRED = False\nACCOUNT_SIGNUP_EMAIL_ENTER_WITHOUT_REQUEST = True # Enable instant signup with email\nACCOUNT_AUTHENTICATION_METHOD = 'email' # Allow login with email, not username\nACCOUNT_EMAIL_VERIFICATION = 'mandatory' # Or 'optional', 'none'\nACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS = 1 # How long email verification links are valid\nLOGIN_REDIRECT_URL = '/'\nACCOUNT_LOGOUT_REDIRECT_URL = '/'\n\n# Add allauth middleware\nMIDDLEWARE = [\n    # ... other middlewares\n    'allauth.account.middleware.AccountMiddleware',\n]\n\n# For testing email in development\nif os.environ.get('DJANGO_SETTINGS_MODULE') == 'your_project.settings': # Example check\n    EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'\n\n# urls.py (in your project's main urls.py)\nfrom django.contrib import admin\nfrom django.urls import path, include\n\nurlpatterns = [\n    path('admin/', admin.site.urls),\n    path('accounts/', include('allauth.urls')),\n    # ... other paths\n]\n","lang":"python","description":"To quickly set up `django-allauth`, first add the necessary apps (`django.contrib.sites`, `allauth`, `allauth.account`, and optionally `allauth.socialaccount` and providers) to your `INSTALLED_APPS`. Configure `SITE_ID=1`. Update `AUTHENTICATION_BACKENDS` to include `allauth.account.auth_backends.AuthenticationBackend`. Ensure `django.template.context_processors.request` is in `TEMPLATES`. Add `allauth.account.middleware.AccountMiddleware` to `MIDDLEWARE`. Finally, include `allauth.urls` in your project's `urls.py` under the `/accounts/` path. Basic settings for email authentication and redirection are also common. Remember to run `python manage.py makemigrations` and `python manage.py migrate` after configuration."},"warnings":[{"fix":"You must explicitly configure IP detection in your `settings.py` by setting `ALLAUTH_TRUSTED_PROXY_COUNT` (number of proxies in front of Django) or `ALLAUTH_TRUSTED_CLIENT_IP_HEADER` (e.g., 'HTTP_CF_CONNECTING_IP' for Cloudflare) to match your deployment architecture. Failing to do so will likely break rate limiting.","message":"Starting with version 65.14.2, IP address detection for rate limiting no longer trusts the `X-Forwarded-For` header by default due to security concerns.","severity":"breaking","affected_versions":"65.14.2+"},{"fix":"Before upgrading `django-allauth`, ensure your Python version is >=3.10 and your Django version is >=4.2 LTS (or 5.0+ for the latest allauth versions). Refer to the official compatibility matrix for exact requirements.","message":"Support for older Python and Django versions has been progressively dropped. Version 64.x dropped Python 3.7 support (requiring 3.8+), and version 65.15.0 dropped Python 3.8 and 3.9 support. Version 63.x dropped Django 3.2 support (requiring Django 4.2+).","severity":"breaking","affected_versions":"63.x, 64.x, 65.15.0+"},{"fix":"Review your custom `allauth` templates. It is recommended to migrate them to use the new element-based system. Alternatively, for a quick fix, ensure your `TEMPLATES` settings do not automatically discover `allauth` templates before your custom ones, allowing your overrides to take precedence.","message":"Version 64.x introduced significant changes to the template system, moving towards an element-based styling approach. Custom templates might not render correctly or benefit from new features.","severity":"breaking","affected_versions":"64.x+"},{"fix":"Do not use `django.contrib.sessions.backends.signed_cookies` as your `SESSION_ENGINE` if you are using `django-allauth`. It stores secrets (like verification codes) in the session, and signed cookies do not encrypt the data, making it insecure.","message":"`django-allauth` is explicitly NOT compatible with `SESSION_ENGINE` set to `django.contrib.sessions.backends.signed_cookies`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If you use social logins, ensure you install `django-allauth` using `pip install \"django-allauth[socialaccount]\"` (and specific provider extras if needed, e.g., `[socialaccount,github]`). Update your `requirements.txt` or `pyproject.toml` accordingly.","message":"As of version 65.3.1, social account functionality requires installing `django-allauth` with the `[socialaccount]` extra. A basic `pip install django-allauth` will no longer include social account dependencies.","severity":"breaking","affected_versions":"65.3.1+"},{"fix":"If you rely on these providers and need existing accounts to link, you will need to manually migrate `SocialAccount.uid` based on the `sub` field in `SocialAccount.extra_data`, or if certain of your use case, set `\"uid_field\": \"preferred_username\"` in the relevant `SocialApp.settings`.","message":"For Okta and NetIQ providers (65.13.0+), the identifier field for `SocialAccount.uid` was switched from `preferred_username` to `sub` due to `preferred_username` being mutable.","severity":"breaking","affected_versions":"65.13.0+"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}