--- id: django-currentuser version: "0.10.0" license: unclear license_treatment: permissive maintenance: aging --- # django-currentuser — Conveniently store reference to request user on thread/db level. License: permissive · Maintenance: aging · Downloads: 204.2K/mo ## 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 above — 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 pip install django-currentuser uv add django-currentuser poetry add django-currentuser ## Installing 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_current - Install friction: low - Maintenance: aging - Downloads: 204.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags django current user middleware, thread-local user reference, auto-populate user field django, get current user django, request user in models, django user context, automatic created_by field, django-middleware, audit-tracking, thread-local [View on SkillFed](https://skillfed.io/packages/django-currentuser) · [View on PyPI](https://pypi.org/project/django-currentuser/)