### Local Project Setup Source: https://github.com/ubernostrum/django-registration/blob/trunk/CONTRIBUTING.rst Installs the project dependencies and creates a local virtual environment using PDM. ```shell pdm install ``` -------------------------------- ### Django URL Configuration for Registration Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/quickstart.rst Example of how to include django-registration's URL patterns in your project's root URLconf. This sets up URLs for registration, completion, and disallowed states, as well as integrating with Django's built-in authentication views. ```python from django.urls import include, path urlpatterns = [ # Other URL patterns ... path("accounts/", include("django_registration.backends.one_step.urls")), path("accounts/", include("django.contrib.auth.urls")), # More URL patterns ... ] ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/ubernostrum/django-registration/blob/trunk/CONTRIBUTING.rst Installs the pre-commit hooks to ensure code formatting and style consistency before committing changes. ```shell pre-commit install ``` -------------------------------- ### Install django-registration (Windows) Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/install.rst Installs the django-registration package using pip on Windows. ```shell py -m pip install django-registration ``` -------------------------------- ### Clone django-registration repository Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/install.rst Clones the django-registration project repository from GitHub using Git for local development. ```shell git clone https://github.com/ubernostrum/django-registration.git ``` -------------------------------- ### License Identifier Comment Source: https://github.com/ubernostrum/django-registration/blob/trunk/CONTRIBUTING.rst Example of a license identifier comment that should be included at the top of new code files. ```python # SPDX-License-Identifier: BSD-3-Clause ``` -------------------------------- ### Install django-registration (macOS/Linux/Unix) Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/install.rst Installs the django-registration package using pip on macOS, Linux, and other Unix-like systems. ```shell python -m pip install django-registration ``` -------------------------------- ### Run Full CI Suite Locally Source: https://github.com/ubernostrum/django-registration/blob/trunk/CONTRIBUTING.rst Executes the complete Continuous Integration suite locally, including tests, documentation checks, linting, formatting, and package building. ```shell nox ``` -------------------------------- ### Django Registration URL Names Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/quickstart.rst Lists the URL names defined by django_registration.backends.one_step.urls, which are used for reversing URLs within the application. ```APIDOC URL Names: django_registration_register: The account-registration view. django_registration_complete: The post-registration success message. django_registration_disallowed: A message indicating registration is not currently permitted. ``` -------------------------------- ### One-Step Registration URL Configuration Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/index.rst Example of how to include django-registration's one-step backend URLs in your Django project's root URL configuration. This setup assumes you are using Django's default authentication URLs as well. ```python from django.urls import include, path urlpatterns = [ # Other URL patterns ... path("accounts/", include("django_registration.backends.one_step.urls")), path("accounts/", include("django.contrib.auth.urls")), # More URL patterns ... ] ``` -------------------------------- ### Activation Complete Template Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/quickstart.rst The 'django_registration/activation_complete.html' template is displayed after successful account activation. It informs the user that their account is now active and has no specific context variables. ```django

Your account has been successfully activated. You can now log in.

``` -------------------------------- ### Django Registration Settings Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/quickstart.rst This documentation entry describes essential Django settings for the django-registration package, specifically for the two-step activation workflow. It covers account activation duration and registration availability. ```APIDOC ACCOUNT_ACTIVATION_DAYS: int - Specifies the number of days users have to activate their accounts after registering. If not activated within this period, the account remains inactive. - Example: ACCOUNT_ACTIVATION_DAYS = 7 REGISTRATION_OPEN: bool - Determines if new account registrations are currently allowed. Defaults to True. - If set to False, all registration attempts will be rejected. URL Names Defined by django_registration.backends.activation.urls: - django_registration_register: The account-registration view. - django_registration_complete: The post-registration success message view. - django_registration_activate: The account-activation view. ``` -------------------------------- ### Run django-registration Tests (Windows) Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/faq.rst Instructions for running the django-registration tests using nox on Windows. This involves installing nox using the py command and then executing nox. ```shell py -m pip install nox py -m nox ``` -------------------------------- ### Ensure pip is installed/upgraded (Windows) Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/install.rst Ensures that pip, the Python package installer, is installed or upgraded on Windows. ```shell py -m ensurepip --upgrade ``` -------------------------------- ### Ensure pip is installed/upgraded (macOS/Linux/Unix) Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/install.rst Ensures that pip, the Python package installer, is installed or upgraded on macOS, Linux, and other Unix-like systems. ```shell python -m ensurepip --upgrade ``` -------------------------------- ### Django Registration Workflow Examples Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/faq.rst This section touches upon different workflows in django-registration, including the one-step workflow for immediate login and the two-step activation workflow. It also mentions manual activation via the admin interface. ```python # For one-step workflow, login occurs immediately after registration. # For two-step activation, toggle 'is_active' field in the admin. ``` -------------------------------- ### Registration Complete Template Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/quickstart.rst The 'django_registration/registration_complete.html' template is displayed after successful registration. It informs the user that an activation email has been sent and has no specific context variables. ```django

Registration successful! Please check your email for activation instructions.

``` -------------------------------- ### Run django-registration Tests (macOS/Linux/Unix) Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/faq.rst Instructions for running the django-registration tests using nox on macOS, Linux, and other Unix-like systems. This involves installing nox and then executing the nox command. ```shell python -m pip install nox python -m nox ``` -------------------------------- ### Include Registration URLs in Django Project Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/quickstart.rst This snippet shows how to integrate django-registration's activation URLs into your main Django URL configuration. It also includes Django's built-in authentication URLs. ```python from django.urls import include, path urlpatterns = [ # Other URL patterns ... path("accounts/", include("django_registration.backends.activation.urls")), path("accounts/", include("django.contrib.auth.urls")), # More URL patterns ... ] ``` -------------------------------- ### Registration Form Template Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/quickstart.rst The 'django_registration/registration_form.html' template is used to display the user registration form. It receives a 'form' context variable, typically a subclass of 'RegistrationForm'. ```django
{% csrf_token %} {{ form.as_p }}
``` -------------------------------- ### Run Tests with Nox Source: https://github.com/ubernostrum/django-registration/blob/trunk/CONTRIBUTING.rst Executes the test suite using nox. By default, it runs against all supported Python versions. You can specify a particular Python version using the --python flag. ```shell nox --tags tests ``` ```shell nox --tags tests --python "3.11" ``` -------------------------------- ### Required Registration Templates Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/quickstart.rst Specifies the HTML template files that need to be created for the django-registration workflow to function correctly. These templates handle the registration form, success message, and closed registration states. ```APIDOC Required Templates: django_registration/registration_form.html django_registration/registration_complete.html django_registration/registration_closed.html ``` -------------------------------- ### Registration Closed Template Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/quickstart.rst The 'django_registration/registration_closed.html' template is rendered when new user account registration is disabled. It does not provide any context variables. ```django

Registration is currently closed. Please try again later.

``` -------------------------------- ### Activation Email Subject Template Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/quickstart.rst The 'django_registration/activation_email_subject.txt' template generates the subject line for the activation email. It has access to 'activation_key', 'expiration_days', 'request', 'scheme', 'site', and 'user'. ```django {% autoescape off %} {{ site.name }} account activation {% endautoescape %} ``` -------------------------------- ### Activation Form Template Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/quickstart.rst The 'django_registration/activation_form.html' template is used for the account activation form. It receives a 'form' context variable with an 'activation_key' field and an 'activation_error' variable if activation fails. ```django {% if activation_error %}

Error: {{ activation_error }}

{% endif %}
{% csrf_token %} {{ form.as_p }}
``` -------------------------------- ### Activation Email Body Template Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/quickstart.rst The 'django_registration/activation_email_body.txt' template generates the body of the activation email, including a link for account activation. It uses context variables like 'activation_key', 'expiration_days', 'request', 'scheme', 'site', and 'user'. ```django {% autoescape off %} Hello {{ user.username }}, Thank you for registering at {{ site.name }}. To activate your account, please click the following link: {{ scheme }}://{{ site.domain }}{% url 'registration_activate' activation_key %} Your activation key is: {{ activation_key }} This key will expire in {{ expiration_days }} days. Sincerely, The {{ site.name }} Team {% endautoescape %} ``` -------------------------------- ### Python HMAC Implementation Reference Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/security.rst This section references the Python standard library's HMAC implementation, which is used by django-registration for cryptographic signing. ```python https://docs.python.org/3/library/hmac.html ``` -------------------------------- ### Django Cryptographic Signing Tools Reference Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/security.rst This section references Django's cryptographic signing tools, which are utilized by django-registration's activation workflow for verifying user signups. ```django https://docs.djangoproject.com/en/1.11/topics/signing/ ``` -------------------------------- ### Include Activation URLs in Django Project Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/activation-workflow.rst Example of how to include the activation URLs provided by django-registration into your project's main URL configuration. This sets up the necessary URL patterns for the registration and activation views. ```python from django.urls import include, path urlpatterns = [ # Other URL patterns ... path('accounts/', include('django_registration.backends.activation.urls')), path('accounts/', include('django.contrib.auth.urls')), # More URL patterns ... ] ``` -------------------------------- ### Check for security issues in Django codebase Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/security.rst This command helps identify common security vulnerabilities within your Django project. It's a recommended step before deploying or making significant changes. ```python python manage.py check --tag security ``` -------------------------------- ### Django Security Documentation Reference Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/security.rst This section references Django's official security documentation, which provides a comprehensive overview of web development security issues and Django's protective measures. ```django https://docs.djangoproject.com/en/stable/#security ``` -------------------------------- ### ReservedNameValidator - django-registration Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/security.rst This class from django-registration enforces restrictions on usernames to prevent impersonation and confusion. It includes a default list of reserved names. ```python from django_registration.validators import ReservedNameValidator ``` -------------------------------- ### Customizing Success URL for Registration Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/one-step-workflow.rst This example demonstrates how to customize the success URL after a user successfully registers using the one-step workflow. It involves subclassing the RegistrationView and specifying a custom success URL. ```python from django.urls import include, path from django_registration.backends.one_step.views import RegistrationView urlpatterns = [ # Other URL patterns ... path('accounts/register/', RegistrationView.as_view(success_url='/profile/'), name='django_registration_register'), path('accounts/', include('django_registration.backends.one_step.urls')), path('accounts/', include('django.contrib.auth.urls')), # More URL patterns ... ] ``` -------------------------------- ### Two-Factor Authentication Integration Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/security.rst Implement two-factor authentication (2FA) for significantly increased user account security. The `django-two-factor-auth` package provides integration with Django's authentication framework, supporting authenticator applications and hardware security keys. ```python # Install the package: # pip install django-two-factor-auth # In settings.py: # INSTALLED_APPS = [ # ... # 'django_otp', # 'django_otp.plugins.otp_totp', # 'django_otp.plugins.otp_hotp', # 'two_factor', # 'two_factor.urls', # ... # ] # Include two_factor URLs in your project's urls.py: # urlpatterns = [ # ... # path('two-factor/', include('two_factor.urls')), # ... # ] ``` -------------------------------- ### Documentation Dependencies Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/requirements.txt These Python packages are required to build the documentation for the django-registration project. They are not installed as regular package extras but are essential for the documentation build process, which typically runs on a newer Python version (e.g., 3.12) than the package's minimum supported version. ```python furo sphinx sphinx-copybutton sphinx-inline-tabs sphinx-notfound-page sphinxext-opengraph ``` -------------------------------- ### ActivationView Rewrite and Workflow Change Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/changelog.rst Describes the rewrite of `ActivationView` and related activation workflow components in version 5.1.0. The primary change is that user account activation now only occurs on HTTP POST requests, enhancing security by preventing activation via GET requests triggered by email clients. ```APIDOC Class: django_registration.views.ActivationView * **Change**: Rewritten in version 5.1.0, impacting the built-in activation workflow. * **Security Enhancement**: User account activation now exclusively occurs on HTTP `POST` requests. * **Previous Behavior**: Previously activated on `GET` requests, posing a security risk due to email client auto-following. * **Backwards Incompatibility**: Activation now requires a `POST` request. * **User Experience Change**: The view displays a form on `GET` requests. * **Template Impact**: Templates associated with the activation view have changed. Refer to the template documentation for required updates. ``` -------------------------------- ### Django Registration Configuration and Usage Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/faq.rst This section provides guidance on configuring django-registration, including how to handle templates, custom user models, and control user signups. It references specific methods and settings within the library. ```python REGISTRATION_OPEN = False # To close user signups ``` ```python from django_registration.views import RegistrationView class CustomRegistrationView(RegistrationView): def registration_allowed(self, request): # Custom logic for registration allowance return True ``` -------------------------------- ### Running Nox Tests for Specific Python Versions Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/faq.rst This snippet demonstrates how to execute Nox tests for a particular Python version using the --python flag. It covers commands for both Unix-like systems and Windows. ```shell python -m nox --python "3.10" ``` ```shell py -m nox --python "3.10" ``` -------------------------------- ### Django URL Configuration for One-Step Registration Source: https://github.com/ubernostrum/django-registration/blob/trunk/README.rst This snippet shows how to include the django-registration URLs in your Django project's root URL configuration for a one-step registration process. It assumes you have already added 'django_registration' to your INSTALLED_APPS. ```python from django.urls import include, path urlpatterns = [ # Other URL patterns ... path("accounts/", include("django_registration.backends.one_step.urls")), path("accounts/", include("django.contrib.auth.urls")), # More URL patterns ... ] ``` -------------------------------- ### Django Registration Activation Workflow API Documentation Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/activation-workflow.rst API documentation for the django-registration activation workflow, detailing the views, forms, and configuration settings involved in the two-step registration process. ```APIDOC Module: django_registration.backends.activation Views: RegistrationView Subclasses base registration views. Customization points specific to this implementation are listed below. ActivationView Subclasses base registration views. Customization points specific to this implementation are listed below. Forms: ActivationForm Located in django_registration.backends.activation.forms. Configuration Settings: ACCOUNT_ACTIVATION_DAYS Specifies the permitted window for account activation. REGISTRATION_OPEN A boolean indicating if registration is currently allowed. REGISTRATION_SALT A salt value used for namespacing HMAC signatures, defaulting to "registration". Security Considerations: Activation keys are generated using Django's cryptographic signing tools (TimestampSigner). The key format is: encoded_username:timestamp:signature. Signature is an HMAC of username and timestamp, using SECRET_KEY and REGISTRATION_SALT. Username and HMAC are URL-safe base64 encoded; timestamp is base62 encoded. Verification includes signature validation and time window check. ``` -------------------------------- ### Preventing Homograph Attacks in Usernames and Emails Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/security.rst django-registration includes validation to prevent homograph attacks by rejecting mixed-script usernames and email addresses that contain visually confusable characters. This validation can be enabled via `validate_confusables` and `validate_confusables_email`. ```python from django_registration.validators import validate_confusables from django_registration.validators import validate_confusables_email # Example usage (within a Django form or model validation): # validate_confusables(username) # validate_confusables_email(email_address) ``` -------------------------------- ### Removal of Model-Based Workflow Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/changelog.rst The legacy two-step model-based signup workflow, present since 2007, has been removed. Users are now recommended to use the two-step activation workflow, which requires no additional server-side storage. ```python Removal of model-based workflow: The two-step model-based signup workflow, which has been present since the first public release of ``django-registration`` in 2007, has now been removed. In its place, it is recommended that you use :ref:`the two-step activation workflow ` instead, as that workflow requires no server-side storage of additional data beyond the user account itself. ``` -------------------------------- ### Django Password Validation Options Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/security.rst Enhance user account security by preventing common passwords. Django's built-in `CommonPasswordValidator` can be used, or for more comprehensive protection, consider the `pwned-passwords-django` package which checks against a large database of breached passwords. ```python from django.contrib.auth.password_validation import CommonPasswordValidator # In settings.py: # PASSWORD_VALIDATORS = [ # 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', # 'django.contrib.auth.password_validation.MinimumLengthValidator', # 'django.contrib.auth.password_validation.CommonPasswordValidator', # 'django.contrib.auth.password_validation.NumericPasswordValidator', # ] # For pwned-passwords-django: # Add 'pwnedpasswords.apps.PwnedPasswordsAppConfig' to INSTALLED_APPS # and include 'pwnedpasswords.validators.PwnedPasswordValidator' in PASSWORD_VALIDATORS. ``` -------------------------------- ### Include One-Step Workflow URLs Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/one-step-workflow.rst This snippet shows how to include the URL configuration for the one-step registration workflow in your project's main URL patterns. It also includes Django's built-in authentication URLs. ```python from django.urls import include, path urlpatterns = [ # Other URL patterns ... path('accounts/', include('django_registration.backends.one_step.urls')), path('accounts/', include('django.contrib.auth.urls')), # More URL patterns ... ] ``` -------------------------------- ### Activation Key Generation Configuration Source: https://github.com/ubernostrum/django-registration/blob/trunk/tests/templates/django_registration/activation_email_body.txt This JSON structure defines parameters for generating activation keys during user registration. It includes the activation key itself, expiration duration in days, the scheme used for URLs, site information, and the username of the user. ```JSON { "activation_key": "{{ activation_key }}", "expiration_days": {{ expiration_days }}, "scheme": "{{ scheme }}", "site": "{{ site }}", "user": "{{ user.username }}" } ``` -------------------------------- ### Email Field Validation Change Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/changelog.rst Explains the modification in email field validation for registration forms starting from version 3.4. The default Django email validator is replaced by django-registration's `HTML5EmailValidator` and `validate_confusables_email`, which are stricter but do not alter the set of accepted email addresses. ```APIDOC Feature: Email Field Validation in Registration Forms * **Change**: Validation no longer uses Django's default email validator. * **New Validators**: Applies `django_registration.validators.HTML5EmailValidator` and `django_registration.validators.validate_confusables_email`. * **Validator Stricter**: django-registration's validators are significantly stricter. * **Accepted Emails**: The set of accepted email addresses remains unchanged, as the new validators are a superset of the previous validation criteria. ``` -------------------------------- ### Django Authentication URL Patterns Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/faq.rst This entry references Django's built-in URL configuration for authentication views, providing a convenient way to include standard auth URLs without manual definition. ```python from django.urls import path, include urlpatterns = [ path('accounts/', include('django.contrib.auth.urls')), # ... other urls ] ``` -------------------------------- ### Success URL Configuration Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/changelog.rst django-registration 3.x offers flexible ways to define success URLs for registration and activation views, aligning with Django's generic views. ```python from django.views.generic.edit import FormMixin from django_registration.views import RegistrationView from django.urls import reverse_lazy class MyRegistrationView(RegistrationView): # Option 1: Set success_url as an attribute (string URL) success_url = '/registration/success/' # Option 2: Implement get_success_url (can optionally take user) def get_success_url(self, user=None): if user: return f'/user/{user.pk}/profile/' return reverse_lazy('registration_complete') # Option 3: Use reverse_lazy for dynamic URLs # success_url = reverse_lazy('registration_success') ``` -------------------------------- ### Activation Key Data Structure Source: https://github.com/ubernostrum/django-registration/blob/trunk/tests/templates/django_registration/activation_email_subject.txt This JSON structure represents the data associated with an activation key, including the key itself, expiration details, site information, and the associated user. ```JSON { "activation_key": "{{ activation_key }}", "expiration_days": {{ expiration_days }}, "scheme": "{{ scheme }}", "site": "{{ site }}", "user": "{{ user.username }}" } ``` -------------------------------- ### django-registration Exception Classes Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/exceptions.rst django-registration provides base exception classes for signup and activation errors. RegistrationError is the base, and ActivationError inherits from it, both storing message, code, and arbitrary parameters. ```APIDOC RegistrationError(message, code, params) Base exception class for all exceptions raised in django-registration. Arguments passed when the exception is raised will be stored and exposed as attributes of the same names on the exception object: Parameters: message (str): A human-readable error message. code (str): A short but unique identifier used by subclasses to distinguish different error conditions. params (dict): Arbitrary key-value data to associate with the error. ActivationError(message, code, params) Exception class to indicate errors during account activation. Subclass of RegistrationError and inherits its attributes. ``` -------------------------------- ### Python 2 and Django 1.11 Support Dropped Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/changelog.rst Support for Python 2 and Django 1.11 has been dropped due to end-of-life status. The minimum supported Django version is now 2.2. ```python Support for Python 2 was dropped, as Python 2 is EOL as of 2020-01-01. As a result, support for Django 1.11 (EOL April 2020) was also dropped; the minimum supported Django version is now 2.2. ``` -------------------------------- ### Renaming of Two-Step Activation Workflow Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/changelog.rst The path for the two-step activation workflow has been renamed from 'registration.backends.hmac' to 'registration.backends.activation'. ```python Renaming of two-step activation workflow: :ref:`The two-step activation workflow ` was previously found at ``registration.backends.hmac``; it has been renamed and is now found at ``registration.backends.activation``. ``` -------------------------------- ### Renaming of One-Step Workflow Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/changelog.rst The path for the one-step workflow has been renamed from 'registration.backends.simple' to its new location. ```python Renaming of one-step workflow: :ref:`The one-step workflow ` was previously found at ``registration.backends.simple``; it has been renamed and is now found at ``` -------------------------------- ### django-registration Version Numbering (DjangoVer) Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/changelog.rst Explains the version numbering system used by django-registration, referred to as "DjangoVer". The format A.B.C indicates the supported Django feature release (A.B) and an incrementing value (C) for django-registration releases supporting that Django version. ```APIDOC Version Numbering (DjangoVer): Format: A.B.C * **A.B**: Version number of the latest supported Django feature release. * **C**: Incrementing value for django-registration releases supporting that Django feature release. **Support Policy**: * A django-registration version supports the Django feature release indicated in its version number. * It also supports any lower-numbered Django feature releases that are actively supported by the Django project at the time of the django-registration release. **Example**: `django-registration` version `5.0.2` indicates support for Django 5.0 and any other Django versions supported by the Django project at that time (e.g., 4.2), and it is the third release of `django-registration` for Django 5.0. ``` -------------------------------- ### Python and Django Version Support Updates Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/changelog.rst Lists the supported Python and Django versions for different releases of django-registration. Version 5.2.0 supports Django 4.2, 5.1, and 5.2. Version 5.1.0 supports Python 3.9-3.13 and Django 4.2, 5.0, and 5.1. ```APIDOC Supported Versions: **Version 5.2.0**: * Django: 4.2, 5.1, 5.2 **Version 5.1.0**: * Django: 4.2, 5.0, 5.1 * Python: 3.9, 3.10, 3.11, 3.12, 3.13 ``` -------------------------------- ### Reserved Names List Update Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/changelog.rst Notes the addition of a new entry, 'xrpc', to the reserved names list in version 3.4. This addition is relevant for domain-ownership verification used by Bluesky/AT protocol. ```APIDOC Feature: Reserved Names List * **Version Added**: 3.4 * **New Entry**: `"xrpc"` * **Purpose**: Used in domain-ownership verification by Bluesky/AT protocol. ``` -------------------------------- ### Compatibility Updates Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/changelog.rst Marks official compatibility with Python 3.7 and Django 2.2. ```python Although no code changes were required, this release officially marks itself compatible with Python 3.7 and with django 2.2. ``` -------------------------------- ### Python and Django Version Support (Latest) Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/changelog.rst Updated supported versions to Django 3.2, 4.1, and 4.2, on Python 3.7 (Django 3.2 only), 3.8, 3.9, 3.10, and 3.11 (Django 4.1 and 4.2 only). ```python The supported Python and Django versions are changed to: Django 3.2, 4.1, and 4.2, on Python 3.7 (Django 3.2 only), 3.8, 3.9, 3.10, and 3.11 (Django 4.1 and 4.2 only). ``` -------------------------------- ### Django Class-Based View Configuration in URLconf Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/faq.rst Illustrates how to modify the behavior of Django class-based views by passing different attribute values directly within the URLconf. This is a common pattern for customizing view behavior without subclassing. ```python from django.urls import path from myapp.views import MyRegistrationView urlpatterns = [ path('register/', MyRegistrationView.as_view(template_name='registration/my_form.html'), name='registration_register'), ] ``` -------------------------------- ### One-Step Workflow Authentication Backend Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/custom-user.rst Explains the authentication backend requirement for the one-step workflow, which needs to accept USERNAME_FIELD and 'password' for authentication. ```python # In settings.py: AUTHENTICATION_BACKENDS = [ 'django.contrib.auth.backends.ModelBackend', # or a custom backend that accepts USERNAME_FIELD and 'password' ] ``` -------------------------------- ### Deleting Expired Unactivated Accounts in Django Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/faq.rst Provides guidance on how to remove user accounts that have not been activated within a specified timeframe. This involves querying for inactive accounts and deleting them. ```python from myapp.models import User from django.utils import timezone # Assuming 'unactivated_since' is a DateTimeField on your User model # or you have a related model tracking activation expired_threshold = timezone.now() - timezone.timedelta(days=7) # Example: 7 days unactivated_users = User.objects.filter(is_active=False, date_joined__lt=expired_threshold) unactivated_users.delete() ``` -------------------------------- ### Custom User Model Handling Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/changelog.rst Improves error handling when using a custom user model without explicitly subclassing RegistrationForm. Previously, this resulted in cryptic errors; now, an ImproperlyConfigured exception with a clear message is raised. ```python When an attempt was made to use ``django-registration`` with a custom user model, but *without* explicitly subclassing :class:`~django_registration.forms.RegistrationForm` to point to that user model, previously the result would be a cryptic exception and error message raised from within Django, complaining about trying to work with the swapped-out user model. :class:`~django_registration.views.RegistrationView` now explicitly raises :exc:`~django.core.exceptions.ImproperlyConfigured` with an informative error message to make it clear what has happened, and directs the developer to the documentation for using custom user models in ``django-registration``. ``` -------------------------------- ### Python and Django Version Support (3.3) Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/changelog.rst Updated supported versions to Django 3.2 and 4.0, on Python 3.7 (Django 3.2 only), 3.8, 3.9, and 3.10. ```python The supported Python and Django versions are changed to: * Django 3.2 and 4.0, on Python 3.7 (Django 3.2 only), 3.8, 3.9, and 3.10. ``` -------------------------------- ### Python and Django Version Support (3.2) Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/changelog.rst Updated supported versions to Django 2.2, 3.1, and 3.2, on Python 3.6, 3.7, 3.8, and 3.9. Python 3.5 and Django 3.0 are no longer supported. ```python The supported Python and Django versions are changed to: * Django 2.2, 3.1, and 3.2, on Python 3.6, 3.7, 3.8, and 3.9. Python 3.5 reached the end of its upstream support cycle in September 2020, and is no longer supported. Django 3.0 reached the end of its upstream support cycle in May 2021, and is no longer supported. ``` -------------------------------- ### ActivationView Base Class Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/views.rst The ActivationView serves as a base class for handling user account activation processes. Developers can subclass this view to create custom activation workflows, with specific customization points outlined in the documentation for provided workflows. ```APIDOC class ActivationView: """Base class for handling user account activation.""" # Attributes and methods for customization can be found in specific workflow documentation. ``` -------------------------------- ### RegistrationForm Methods Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/forms.rst Details the clean and save methods for the RegistrationForm class, which handles user account information and registration constraints. ```APIDOC RegistrationForm: clean() Cleans the data in the form. save() Saves the user and returns the user instance. ``` -------------------------------- ### ActivationError Exception Handling Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/changelog.rst Activation failures in django-registration 3.x raise an ActivationError exception, which can be caught and handled by the ActivationView. ```python from django_registration.exceptions import ActivationError try: # Attempt to activate user pass except ActivationError as e: # Handle activation failure, e.g., log the error or display a message print(f"Activation failed: {e.code}") ``` -------------------------------- ### URL Pattern Renaming in django-registration 3.x Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/changelog.rst Explains the renaming of URL pattern names in django-registration's included URLconf modules. The prefix changed from 'registration' to 'django_registration' for better project identification. ```text URL Pattern Name Prefix: Prior to 3.x: ``registration_`` (e.g., ``registration_register``) In 3.x: ``django_registration_`` (e.g., ``django_registration_register``) ``` -------------------------------- ### RegistrationFormTermsOfService Class Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/forms.rst Represents a registration form that includes terms of service acceptance. ```APIDOC RegistrationFormTermsOfService: Inherits from RegistrationForm and adds a field for terms of service agreement. ``` -------------------------------- ### Custom User Model Requirements Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/changelog.rst Custom user models in django-registration 3.x require specific methods to be implemented for compatibility. ```python from django.contrib.auth.models import AbstractBaseUser class CustomUser(AbstractBaseUser): USERNAME_FIELD = 'email' def get_username(self): return self.email def get_email_field_name(self): return 'email' ``` -------------------------------- ### Two-Step Activation Workflow Requirements Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/custom-user.rst Specifies the additional requirement for the two-step activation workflow: the user model must have an 'is_active' BooleanField. ```python from django.db import models class CustomUser(AbstractUser): # ... other fields ... is_active = models.BooleanField( 'active', default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', ) ``` -------------------------------- ### Module Renaming: registration to django_registration Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/changelog.rst In version 3.x, the Python module name was changed from 'registration' to 'django_registration' to avoid silent incompatibilities and adhere to best practices. Importing from the old module will now raise an ImportError. ```python Module renaming: Prior to 3.x, ``django-registration`` installed a Python module named ``registration``. To avoid silent incompatibilities, and to conform to more recent best practices, ``django-registration`` 3.x now installs a module named ``django_registration``. Attempts to import from the ``registration`` module will immediately fail with :exc:`ImportError`. Many installations will be able to adapt by replacing references to ``registration`` with references to ``django_registration``. ``` -------------------------------- ### API Stability and Deprecations Policy Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/changelog.rst Details the policy for API stability and deprecations in django-registration. It covers what constitutes the stable public API, the process for removing or changing public APIs with deprecation warnings, and exceptions for security fixes or critical bug fixes. ```APIDOC API Stability and Deprecations Policy: * **Stable Public API**: The set of symbols documented in this documentation. For classes, this includes documented methods and attributes whose names do not start with an underscore (_). * **Deprecation Warnings**: Public APIs slated for removal or backwards-incompatible changes will emit deprecation warnings for at least two releases before the change occurs. * **Exceptions**: Security fixes and high-severity bug fixes (e.g., those causing crashes or data loss) may impose backwards-incompatible changes without prior warnings, if necessary. Such cases will be noted in the changelog. * **Policy Effective Date**: This policy is in effect as of version 5.0.0 of django-registration, coinciding with the adoption of "DjangoVer" versioning. ``` -------------------------------- ### Including Django Auth URLs Source: https://github.com/ubernostrum/django-registration/blob/trunk/docs/changelog.rst In django-registration 3.x, auth views are no longer automatically configured. You need to explicitly include Django's auth URLs. ```python from django.urls import include, path urlpatterns = [ # ... other urls path('accounts/', include('django.contrib.auth.urls')), # ... other urls ] ```