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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 66.3MB
glibcpy 3.10–3.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.fixAdd 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.fixCall '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.fixUse '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().fixOverride 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