django-crum
Django middleware to capture current request and user.
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-crumuv
uv add django-crumpoetry
poetry add django-crumInstalling 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
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
dj-inmemorystorageAn in-memory storage backend for Django that…
permissive · top 15,000 on PyPI
django-currentuserStores a reference to the currently logged-in…
permissive · top 15,000 on PyPI
django-easy-auditLogs every CRUD operation, authentication…
copyleft · top 15,000 on PyPI
django-hijackDjango Hijack lets administrators impersonate…
permissive · top 5,000 on PyPI
django-safedeleteProvides soft-delete functionality for Django…
permissive · top 5,000 on PyPI
django-logentry-adminRegisters Django's built-in LogEntry model in…
permissive · top 15,000 on PyPI
django-hashidsProvides a Django model field that proxies…
permissive · top 15,000 on PyPI
django-session-timeoutAdds automatic session expiration to Django…
permissive · top 15,000 on PyPI
django-pghistoryTracks all changes to Django models using…
permissive · top 15,000 on PyPI
django-impersonateAllows Django superusers to temporarily assume…
permissive · top 15,000 on PyPI