django-currentuser
Conveniently store reference to request user on thread/db level.
What it is and what it does
django-currentuser is a Django middleware and model field that automatically captures and stores the currently logged-in user at the thread level, making it accessible throughout your request lifecycle without explicitly passing it as a parameter. It provides two main components: a middleware class that captures the user from each request, and a CurrentUserField that automatically populates model fields with the current user when instances are created or updated.
The package solves the common problem of tracking who created or modified a record without cluttering your views and model methods with user-passing logic. It stores the user reference at the moment a model instance is initialized, allowing you to override it before saving if needed. The middleware is compatible with Django 4.2, 5.2, and 6.0, and supports modern Python versions.
Use it for:
- Automatically populate created_by and updated_by fields on models without passing user through every layer
- Access the current user in model methods, signals, or business logic without threading it through function parameters
- Audit logging: track which user performed each database operation without explicit parameter passing
- Multi-tenant applications where you need the current user context available globally within a request
- Testing: retain user context after request completion for test assertions
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Stores a reference to the currently logged-in request user at the thread level, making it accessible throughout your Django application without passing it as a parameter.
Yes, if you are using Django 4.2 or later and want to reduce boilerplate for tracking user ownership of records. The package is stable, permissively licensed, and has no known vulnerabilities. The aging maintenance status (205 days since last release) is not a blocker for a mature, narrowly-scoped library, but monitor the repository for Django 6.0+ compatibility as new versions arrive.
Install
django-currentuser on PyPI
pip
pip install django-currentuseruv
uv add django-currentuserpoetry
poetry add django-currentuserInstalling django-currentuser
Before you install
Low install friction with a single Django dependency. Maintenance status is aging—last release was 205 days ago—but the repository remains active and the package supports current Python versions (3.10–3.14) and recent Django versions (4.2, 5.2, 6.0).
License in practice
Licensed under BSD (permissive), which allows commercial and private use with minimal restrictions.
Quickstart
pip install django-currentuser
# In settings.py MIDDLEWARE:
MIDDLEWARE = (
...,
'django_currentuser.middleware.ThreadLocalUserMiddleware',
)
# In models.py:
from django_currentuser.db.models import CurrentUserField
class Foo(models.Model):
created_by = CurrentUserField()
updated_by = CurrentUserField(on_update=True)
Requires Django 4.2 or later; if you need an unsupported Django version, set DJANGO_CURRENTUSER_USE_UNSUPPORTED_DJANGO=1 before install.
Verify before relying
- Performance impact of thread-local storage in high-concurrency environments
- Compatibility with async Django views or ASGI deployments
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — Django |
| Maintenance | aging — 205 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 204,208/month — #9,614 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_currentuser-0.10.0-py3-none-any.whl
Tags
More Dynamic Content packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
soupsieveSoupsieve is a CSS selector library designed to…
permissive · top 100 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
FlaskFlask is a lightweight WSGI web application…
permissive · top 1,000 on PyPI
MakoMako compiles Python-embedded templates into…
permissive · top 1,000 on PyPI
django-crumDjango-CRUM stores the current request and user…
permissive · top 15,000 on PyPI
django-browser-reloadAutomatically reloads your browser when you…
permissive · top 15,000 on PyPI
django-dirtyfieldsTracks which fields on a Django model instance…
permissive · top 15,000 on PyPI
django-request-idAttaches a unique request ID to each Django…
permissive · top 15,000 on PyPI
django-registrationProvides user registration workflows for Django…
permissive · top 15,000 on PyPI
django-cprofile-middlewareMiddleware that profiles Django view execution…
permissive · top 15,000 on PyPI
django-decorator-includeApplies decorators to Django URL patterns…
permissive · top 15,000 on PyPI
django-structlogIntegrates structured logging into Django…
permissive · top 5,000 on PyPI
django-upgradeAutomatically modernizes Django project code by…
permissive · top 15,000 on PyPI
django-model-utilsProvides reusable model mixins and field…
permissive · top 5,000 on PyPI