Skip to main content

About

django-user-activation is a Django app to manage user activation on registration.

Requirements

  • Python >= 3.10

  • Django >= 5.0

Setup

Install from pip:

python -m pip install django-user-activation

and then add it to your installed apps:

INSTALLED_APPS = [
    ...,
    "django_user_activation",
    ...,
]

Configuration

  • Ensure that django_user_activation’s URLs are included in your project’s urls.py:

    from django.urls import path, include
    
    urlpatterns = [
        ...,
        path('user/', include('django_user_activation.urls')),
        ...,
    ]
  • Configure the behaviour in your Django settings:

    • USER_ACTIVATION_TOKEN_LIFE: int | float

      The number of seconds that the activation token is valid for. Default is 3600 (1 hour).

    • USER_ACTIVATION_EMAIL_SUBJECT: str

      The subject of the activation email. Default is “Email Verification”.

    • USER_ACTIVATION_WITH_CELERY: bool

      Whether to use Celery to send the activation email. Default is False. If set to True, you must have Celery set up and configured in your project.

    • USER_ACTIVATION_LOGGER: bool

      Whether to log activation events. Default is False.

  • Configure the email backend in your Django settings:

    EMAIL_HOST = 'smtp.example.com'
    EMAIL_PORT = 587
    EMAIL_USE_TLS = True
    EMAIL_HOST_USER = ''
    EMAIL_HOST_PASSWORD = ''
  • Templates
    • You can override the templates used by django-user-activation by creating your own templates in your project under the templates/user_activation directory.

    • The templates that can be overridden are:
      • django_user_activation/user_activation.html

      • django_user_activation/user_activation.txt

Example Usage

...
from django_user_activation import send_activation_email
...


def register(request):
    if request.method == "POST":
        form = UserRegistrationForm(request.POST)
        if form.is_valid():
            user = form.save(commit=False)
            user.is_active = False
            user.save()
            send_activation_email(request, user)
            ...

Testing

To run the tests, clone the repository and install the requirements:

python -m pip install -r requirements.txt

and then run:

python manage.py test

Release files for django-user-activation 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-user-activation 1.0.0
File Size Uploaded
django_user_activation-1.0.0.tar.gz 7.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-user-activation 1.0.0
File Interpreter ABI Platform
django_user_activation-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.9 kB

Release files / django_user_activation-1.0.0.tar.gz

Download URL django_user_activation-1.0.0.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
62bc2cbf46308e5b250199bf9c7ccb44d74aa82ed9a64b88de90e624baa21560
BLAKE2b-256 checksum
How to use checksums
e45edeb4a7b6ac5b1646ab14866a90c03ce5dac2967ca86a28af765af71a06ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / django_user_activation-1.0.0-py3-none-any.whl

Download URL django_user_activation-1.0.0-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ebde67e54936c1874e6d417954effea424d816632961f615dfaba7e89a0a5813
BLAKE2b-256 checksum
How to use checksums
069f24d83ff7c74793c094997b0d83d14fc34cbfbf591dee7a11ec2eb2c1a282
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page