skillfed

django-currentuser

Conveniently store reference to request user on thread/db level.

django-currentuser v0.10.0 204.2K downloads/30d#9,614 on PyPI177
Permissive license AGING released

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-currentuser

uv

uv add django-currentuser

poetry

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 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

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

Tags

django current user middlewarethread-local user referenceauto-populate user field djangoget current user djangorequest user in modelsdjango user contextautomatic created_by field
django-middlewareaudit-trackingthread-local

More Dynamic Content packages

MarkupSafe

MarkupSafe provides a text object that escapes…

permissive · top 100 on PyPI

Jinja2

Jinja2 is a templating engine that renders…

permissive · top 100 on PyPI

soupsieve

Soupsieve is a CSS selector library designed to…

permissive · top 100 on PyPI

Werkzeug

Werkzeug is a WSGI utility library providing…

permissive · top 1,000 on PyPI

Flask

Flask is a lightweight WSGI web application…

permissive · top 1,000 on PyPI

Mako

Mako compiles Python-embedded templates into…

permissive · top 1,000 on PyPI

django-crum

Django-CRUM stores the current request and user…

permissive · top 15,000 on PyPI

django-browser-reload

Automatically reloads your browser when you…

permissive · top 15,000 on PyPI

django-dirtyfields

Tracks which fields on a Django model instance…

permissive · top 15,000 on PyPI

django-request-id

Attaches a unique request ID to each Django…

permissive · top 15,000 on PyPI

django-registration

Provides user registration workflows for Django…

permissive · top 15,000 on PyPI

django-cprofile-middleware

Middleware that profiles Django view execution…

permissive · top 15,000 on PyPI

django-decorator-include

Applies decorators to Django URL patterns…

permissive · top 15,000 on PyPI

django-structlog

Integrates structured logging into Django…

permissive · top 5,000 on PyPI

django-upgrade

Automatically modernizes Django project code by…

permissive · top 15,000 on PyPI

django-model-utils

Provides reusable model mixins and field…

permissive · top 5,000 on PyPI