{"id":8953,"library":"django-registration","title":"Django Registration","description":"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.","status":"active","version":"5.2.1","language":"en","source_language":"en","source_url":"https://github.com/ubernostrum/django-registration","tags":["Django","registration","user management","authentication","accounts"],"install":[{"cmd":"pip install django-registration","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core framework dependency. Requires Django >=3.9, officially supports 4.2, 5.0, 5.1, 5.2 for version 5.x.","package":"Django","optional":false}],"imports":[{"symbol":"RegistrationForm","correct":"from django_registration.forms import RegistrationForm"},{"note":"Older versions used 'registration' and 'simple' backend. Current versions use 'django_registration' and specific backend paths like 'one_step'.","wrong":"from registration.backends.simple import urls","symbol":"one_step.urls","correct":"from django_registration.backends.one_step import urls as one_step_urls"},{"note":"Older versions used 'registration' and 'default' backend. Current versions use 'django_registration' and specific backend paths like 'activation'.","wrong":"from registration.backends.default import urls","symbol":"activation.urls","correct":"from django_registration.backends.activation import urls as activation_urls"}],"quickstart":{"code":"import os\n\n# settings.py\nINSTALLED_APPS = [\n    'django.contrib.admin',\n    'django.contrib.auth',\n    'django.contrib.contenttypes',\n    'django.contrib.sessions',\n    'django.contrib.messages',\n    'django.contrib.staticfiles',\n    'django.contrib.sites',\n    'django_registration',\n    # 'django_registration.backends.activation', # Optional, explicitly if only using activation backend\n    # 'django_registration.backends.one_step', # Optional, explicitly if only using one-step backend\n]\n\nSITE_ID = 1 # Required by django.contrib.sites, which django-registration uses.\nACCOUNT_ACTIVATION_DAYS = 7 # Required for the two-step activation workflow.\n\n# Configure email backend for activation (example using console)\nEMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'\n\n# Optionally, redirect after login (Django's built-in auth uses this)\nLOGIN_REDIRECT_URL = '/'\nLOGOUT_REDIRECT_URL = '/'\n\n# urls.py\nfrom django.urls import include, path\n\nurlpatterns = [\n    path('admin/', include('admin.site.urls')),\n    path('accounts/', include('django_registration.backends.one_step.urls')), # For one-step registration\n    path('accounts/', include('django.contrib.auth.urls')), # For login, logout, password reset etc.\n]\n\n# Remember to run migrations: python manage.py migrate","lang":"python","description":"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."},"warnings":[{"fix":"Review the `RegistrationForm` and `ActivationView` documentation for version 5.1.0+ and test custom registration flows thoroughly. Custom forms might need to be re-evaluated for compatibility with the new base form structure.","message":"Version 5.1.0 significantly refactored `RegistrationForm` (no longer subclassing Django's `UserCreationForm`) and `ActivationView`. While designed for backwards compatibility, projects with highly customized forms or activation logic might require adjustments, especially when interacting with custom user models.","severity":"breaking","affected_versions":"5.1.0+"},{"fix":"Upgrade your Django project to a supported version (e.g., Django 4.2 LTS or 5.x) and ensure your Python environment is 3.9 or higher before installing `django-registration` 5.x.","message":"Older versions (pre-3.0) dropped Python 2 and Django 1.11 support. The current 5.x series requires Python >=3.9 and supports Django 4.2, 5.0, 5.1, and 5.2. Ensure your Python and Django versions meet these requirements before upgrading `django-registration`.","severity":"breaking","affected_versions":"<3.0, <5.1.0 (for older Django versions)"},{"fix":"Adjust `INSTALLED_APPS` order in `settings.py`: `INSTALLED_APPS = ['...', 'django_registration', 'django.contrib.admin', '...']`","message":"For templates to render correctly, `django_registration` (or `registration` in older versions) should be listed *above* `django.contrib.admin` in your `INSTALLED_APPS` setting.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If you need to allow usernames/email addresses that conflict with these validators, consult the `django-registration` documentation on form customization or disabling specific validators. For example, you can replace the default `RegistrationForm` with a custom one that omits or modifies these validators.","message":"Version 2.1 introduced `ReservedNameValidator`, which prevents registration of certain usernames (e.g., 'admin', 'root'). This validator is applied by default. Similarly, `HTML5EmailValidator` was added in 5.0.0, which is more restrictive for email addresses.","severity":"gotcha","affected_versions":"2.1+, 5.0.0+"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure `pip install django-registration` was run and add `'django_registration'` to your `INSTALLED_APPS` in `settings.py`.","cause":"The 'django_registration' app is not listed in `INSTALLED_APPS` in your Django project's settings, or the package was not installed.","error":"ModuleNotFoundError: No module named 'django_registration'"},{"fix":"Add `ACCOUNT_ACTIVATION_DAYS = 7` (or your desired number of days) to your `settings.py` file.","cause":"You are using the two-step activation workflow (`django_registration.backends.activation.urls`) but have not defined the `ACCOUNT_ACTIVATION_DAYS` setting.","error":"django.core.exceptions.ImproperlyConfigured: ACCOUNT_ACTIVATION_DAYS setting must be specified"},{"fix":"Ensure your view passes the form instance that was populated with `request.POST` data to the template when validation fails. Do not create a new `SignUpForm()` after `is_valid()` check: `if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): ... else: return render(request, 'registration/registration_form.html', {'form': form})`","cause":"In your view, if `form.is_valid()` returns `False`, you are likely re-instantiating an empty form instead of rendering the original form which contains the validation errors.","error":"Your registration form shows no errors when submission fails, just a blank form."},{"fix":"This is expected behavior. The user should be informed that the username/email is taken. Ensure your form templates correctly display `form.errors` and specific field errors to the user. `django-registration`'s default forms handle this automatically.","cause":"A user tried to register with a username (or email, if `USERNAME_FIELD` is email) that already exists in the database.","error":"django.db.utils.IntegrityError: UNIQUE constraint failed: auth_user.username"}]}