skillfed

django-crum

Django middleware to capture current request and user.

django-crum v0.7.9 441.3K downloads/30d#6,644 on PyPI102
Permissive license BSD DORMANT released

What it is and what it does

Django-CRUM is a middleware package that captures the current HTTP request and authenticated user into thread-local storage, allowing your code to access them anywhere in your application without threading the request object through function calls. It's particularly useful for audit logging, permission checks, and other cross-cutting concerns that need to know who made the current request.

The package includes a context manager for temporarily impersonating another user and exposes a signal to customize how the current user is determined, which can help when using custom authentication methods or non-standard user models. It depends only on django and installs as a simple wheel with no compiled dependencies.

Use it for:

  • Audit logging: capture which user performed an action without passing request through every function layer
  • Permission checks: verify user permissions in business logic without request object available
  • Temporary user impersonation: switch context to another user for a specific operation block
  • Custom authentication: extend the current-user detection via signals for non-standard auth backends

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Django-CRUM stores the current request and user in thread-local storage, making them accessible throughout your application without passing the request object explicitly.

Yes, if you are on Django versions up to 3.1 and do not need active maintenance. The package is stable and lightweight for its intended use case, but dormant since 2020 means no support for newer Django releases. Install only if your project's Django version is within the tested range and you accept that updates will not arrive.

Install

django-crum on PyPI

pip

pip install django-crum

uv

uv add django-crum

poetry

poetry add django-crum

Installing django-crum

Before you install

Low install friction with a single dependency on django. Maintenance is dormant—last release was 2020-11-10 with no commits since 2024-02-22—so expect no active bug fixes or updates.

License in practice

BSD license (permissive) places no restrictions on use, modification, or distribution in your own projects.

Quickstart

pip install django-crum

# In Django settings.py, add to MIDDLEWARE:
# 'crum.CurrentRequestUserMiddleware'

from crum import get_current_user
user = get_current_user()

Requires django as a runtime dependency; thread-local storage behavior in async contexts is not documented in the fact sheet.

Verify before relying

  • Whether the package works reliably with Django versions released after 2020-11-10
  • Current behavior and support status in async Django contexts
  • Whether the custom user model signal extension works with all modern Django authentication backends

Package facts

License BSD (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 1 — django
Maintenance dormant — 2,103 days since the last release
Last repo commit
First released
Downloads 441,301/month — #6,644 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: django_crum-0.7.9-py2.py3-none-any.whl

Keywords: django, request, user, middleware, thread, local

Development Status :: 4 - BetaEnvironment :: Web EnvironmentFramework :: DjangoFramework :: Django :: 1.11Framework :: Django :: 2.0Framework :: Django :: 2.1Framework :: Django :: 2.2Framework :: Django :: 3.0Framework :: Django :: 3.1Intended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Internet :: WWW/HTTPTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python Modules

Tags

django current request middlewarethread local request storagedjango user context accesscapture current user djangorequest context middlewaredjango audit trail userthread local user storage
django-middlewarethread-local-storageaudit-logging

More Libraries packages