Registry / web-framework / django-currentuser

django-currentuser

JSON →
library0.10.0pypypiunverified

A Django middleware and model mixin that automatically saves the current request user as the creator/last modifier of model instances. Version 0.10.0 supports Django 4.2-5.1, Python >=3.10. Released roughly twice per year.

pip install django-currentuser
INSTALL
IMPORT
SIG · DJANGO-CURRENTUSER
D
django-currentuser
web-frameworkpythonv0.10.0
Install
3.4s avg
Import
Disk
65MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.10.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 66.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.4s · import 0.000s · 67MB
65MB installed
● package 65MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

get_current_user
from django_currentuser.middleware import get_current_user
from django_currentuser.middleware import get_current_user

Configure middleware and use CurrentUserField in models to auto-populate creator/updater.

# settings.py INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', ... ] MIDDLEWARE = [ 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django_currentuser.middleware.CurrentUserMiddleware', ... ] # models.py from django.db import models from django_currentuser.db.models import CurrentUserField class Article(models.Model): title = models.CharField(max_length=255) created_by = CurrentUserField() updated_by = CurrentUserField(on_update=True) # migrate and use normally from django_currentuser.middleware import get_current_user user = get_current_user() # returns request.user or None
Debug
Known issues
gotchaCurrentUserField on_update=True requires the field to be nullable or have a default, otherwise saving an existing object without an explicit user will fail.
fix
Add null=True, blank=True to the field or ensure get_current_user() never returns None.
affects: all
gotchaUsing get_current_user() outside of a request (e.g., in management commands, tests, or Celery tasks) returns None unless you manually set the thread-local user.
fix
Call 'from django_currentuser.middleware import set_current_user; set_current_user(user)' before accessing get_current_user().
affects: all
deprecatedThe import path 'from django_currentuser.fields import CurrentUserField' is deprecated since v0.5.0.
fix
Use 'from django_currentuser.db.models import CurrentUserField'.
affects: >=0.5.0, <0.10.0
gotchaThe update_on_save feature does not work with bulk_create or bulk_update; the current user is only set on individual model save().
fix
Override bulk operations to set the user explicitly, or avoid bulk create/update on models with CurrentUserField.
affects: all
Upgrade
Version history
0.10.0latest on PyPI · released Jan 21, 2026
Audit
Dependencies
djangorequiredPrimary framework; version >=4.2 required
Agent activity
4 hits · last 30 days
node
4
Resources
django-currentuser — pip install django-currentuser · libregistry