Django Registration

5.2.1 · active · verified Thu Apr 16

Django Registration (django-registration) is an extensible application that provides user registration functionality for Django websites. It supports common registration workflows, including two-step (email activation) and one-step (immediate login), and is designed to work with both Django's default and custom user models. Currently at version 5.2.1, it follows a 'DjangoVer' versioning scheme, ensuring compatibility with supported Django feature releases.

Common errors

Warnings

Install

Imports

Quickstart

To quickly set up `django-registration`, add `django_registration` to your `INSTALLED_APPS`. For the two-step activation workflow, define `ACCOUNT_ACTIVATION_DAYS` in your `settings.py`. Then, include the appropriate URL patterns in your project's `urls.py` (e.g., `django_registration.backends.one_step.urls` or `django_registration.backends.activation.urls`), typically under an `/accounts/` prefix, alongside Django's built-in `django.contrib.auth.urls`. Ensure `django.contrib.sites` is also installed and `SITE_ID` is configured.

import os

# settings.py
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'django_registration',
    # 'django_registration.backends.activation', # Optional, explicitly if only using activation backend
    # 'django_registration.backends.one_step', # Optional, explicitly if only using one-step backend
]

SITE_ID = 1 # Required by django.contrib.sites, which django-registration uses.
ACCOUNT_ACTIVATION_DAYS = 7 # Required for the two-step activation workflow.

# Configure email backend for activation (example using console)
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

# Optionally, redirect after login (Django's built-in auth uses this)
LOGIN_REDIRECT_URL = '/'
LOGOUT_REDIRECT_URL = '/'

# urls.py
from django.urls import include, path

urlpatterns = [
    path('admin/', include('admin.site.urls')),
    path('accounts/', include('django_registration.backends.one_step.urls')), # For one-step registration
    path('accounts/', include('django.contrib.auth.urls')), # For login, logout, password reset etc.
]

# Remember to run migrations: python manage.py migrate

view raw JSON →