django-impersonate
Django app to allow superusers to impersonate other users.
What it is and what it does
django-impersonate is a Django application that enables superusers to temporarily log in as other non-superuser accounts without needing their passwords. This is useful for debugging user-specific issues, testing permission systems, and providing support. The package injects an `is_impersonate` flag and an `impersonator` reference into the request object so your code can detect and audit when impersonation is active. It provides URL endpoints to start impersonation, stop it, list available users, and search for users to impersonate.
The package has no runtime dependencies beyond Django itself and relies on Django's built-in session framework. It includes middleware that integrates with Django's authentication system and provides signals you can hook into for audit logging. Configuration is optional—you can restrict which users can impersonate others and which users can be impersonated by defining custom allow/queryset functions.
Use it for:
- Debug a specific user's issue by impersonating their account and reproducing the problem in their context
- Test permission and access control logic by switching to accounts with different roles
- Provide customer support by temporarily viewing the application as a customer sees it
- Audit user actions by logging impersonation sessions via the provided signals
- Verify that certain features are correctly restricted to specific user types
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Allows Django superusers to temporarily assume the identity of other user accounts for testing and support purposes, with the original user remaining traceable.
Yes, with conditions. The package is stable, permissively licensed, and widely used. However, install friction is high (source distribution only), and maintenance is aging (496 days since last release). Install it if you need user impersonation in a Django admin context and can accept slower update cycles; avoid it if you require frequent security patches or active upstream support.
Install
django-impersonate on PyPI
pip
pip install django-impersonateuv
uv add django-impersonatepoetry
poetry add django-impersonateInstalling django-impersonate
Before you install
High install friction due to source distribution only. Maintenance status is aging—last release was 496 days ago. The package is stable and widely used (top 15000 on PyPI), but slow update cadence may indicate limited active development.
License in practice
BSD License (permissive). You may use, modify, and distribute this package freely in commercial and private projects, with minimal restrictions.
Quickstart
pip install django-impersonate
# In settings.py:
INSTALLED_APPS = [
...
'impersonate',
]
MIDDLEWARE = [
...
'impersonate.middleware.ImpersonateMiddleware',
]
# In urls.py:
urlpatterns = [
path('impersonate/', include('impersonate.urls')),
]
# Then visit /impersonate/<user-id>/ to start impersonation
Requires Django's session framework (django.contrib.sessions) to be enabled. ImpersonateMiddleware must be placed after django.contrib.auth middleware.
Verify before relying
- Whether the XSS vulnerability mentioned for versions 1.9.3 and below has been fully resolved in 1.9.5
- Current maintenance status and whether the 496-day gap since last release indicates active or dormant development
Package facts
| License | BSD License (permissive) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | aging — 496 days since the last release |
| First released | |
| Downloads | 268,816/month — #8,267 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_impersonate-1.9.5.tar.gz
Tags
More Dynamic Content packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
soupsieveSoupsieve is a CSS selector library designed to…
permissive · top 100 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
FlaskFlask is a lightweight WSGI web application…
permissive · top 1,000 on PyPI
MakoMako compiles Python-embedded templates into…
permissive · top 1,000 on PyPI
django-hijackDjango Hijack lets administrators impersonate…
permissive · top 5,000 on PyPI
django-loginasAdds a "Log in as user" button to the Django…
permissive · top 5,000 on PyPI
primpHTTP client library that mimics real web…
permissive · top 5,000 on PyPI
scrapy-impersonateA Scrapy download handler that replaces…
permissive · top 15,000 on PyPI
django-magiclinkAdds passwordless email-based authentication to…
permissive · top 15,000 on PyPI
django-crumDjango-CRUM stores the current request and user…
permissive · top 15,000 on PyPI
django-logentry-adminRegisters Django's built-in LogEntry model in…
permissive · top 15,000 on PyPI
django-auth-adfsIntegrates Django applications with Microsoft…
permissive · top 15,000 on PyPI
django-permissionedformsExtends Django's forms framework to…
permissive · top 5,000 on PyPI
django-maintenance-modeActivates a 503 maintenance page in Django…
permissive · top 15,000 on PyPI