django-currentuser
Conveniently store reference to request user on thread/db level.
Decision gist · record as of 2026-08-14
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.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Django 4.2 or later; if you need an unsupported Django version, set DJANGO_CURRENTUSER_USE_UNSUPPORTED_DJANGO=1 before 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 · maintenance · safety
permissive license (permissive) — Licensed under BSD (permissive), which allows commercial and private use with minimal restrictions.
last release 2026-01-21 (205 days) · last repo commit 2026-01-21 · 177 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 204,208 downloads/mo, #9,614 on PyPI
Alternatives
Verify before relying
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)- Performance impact of thread-local storage in high-concurrency environments
- Compatibility with async Django views or ASGI deployments
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 on it.
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
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).
Requires Django 4.2 or later; if you need an unsupported Django version, set DJANGO_CURRENTUSER_USE_UNSUPPORTED_DJANGO=1 before install.
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)
Verify before relying
- Performance impact of thread-local storage in high-concurrency environments
- Compatibility with async Django views or ASGI deployments
Package facts
| License | permissive license permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packageDjango |
| 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 |
| Classifiers | Development Status :: 4 - BetaFramework :: DjangoFramework :: Django :: 4.2Framework :: Django :: 5.2Framework :: Django :: 6.0Intended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14 |
Evidence: django_currentuser-0.10.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “thread-local user reference”
- django-currentuserStores a reference to the currently logged-in request user at the…
- oslo.contextoslo.context provides utilities to store and access request context…
- django-crumDjango-CRUM stores the current request and user in thread-local…
Give your agent the search over MCP, or paste the wish link into any chat.
More Dynamic Content packages
MarkupSafe provides a text object that escapes special characters so untrusted strings can be safely embedded in HTML and XML without injection attacks.
Jinja2 is a templating engine that renders dynamic content by combining templates with Python-like syntax and data, supporting template inheritance, macros, autoescaping, and sandboxed execution.
Soupsieve is a CSS selector library designed to work with Beautiful Soup 4 to select, match, and filter HTML and XML elements using modern CSS selectors from CSS level 1 through CSS level 4 specifications.
Install it if you use Beautiful Soup for HTML or XML parsing and want modern CSS selector support.
Werkzeug is a WSGI utility library providing request/response objects, URL routing, an interactive debugger, HTTP utilities, and a development server for building web applications.
Flask is a lightweight WSGI web application framework for building web applications in Python, from simple single-page sites to complex multi-route applications.
Mako compiles Python-embedded templates into Python modules for fast rendering, supporting layout inheritance, custom functions, and direct Python expressions within template syntax.
See also django-crum · django-browser-reload · django-dirtyfields · django-request-id · django-registration · django-cprofile-middleware · django-decorator-include · django-structlog · django-upgrade · django-model-utils