Skip to main content

Django app to allow superusers to impersonate other users.

Project description


Simple application to allow superusers to "impersonate" other
non-superuser accounts.


It was written for Python 2.4+ and Django 1.2.4 but it should
work just fine with Django 1.1+

It depends on your project using the django.contrib.session framework.



pip install django-impersonate

Basic Manual Install:

$ python build
$ sudo python install

Alternative Install (Manually):

Place impersonate directory in your Python path. Either in your Python
installs site-packages directory or set your $PYTHONPATH environment
variable to include a directory where the webutils directory lives.

1) Add 'impersonate' to your INSTALLED_APPS

2) Add 'impersonate.middleware.ImpersonateMiddleware' to your MIDDLEWARE_CLASSES

3) Add 'impersonate.urls' somewhere in your url structure. Example:

urlpatterns = patterns('',
url(r'^admin/', include(,
url(r'^impersonate/', include('impersonate.urls')),

... (all your other urls here) ...

You can now impersonate another user by hitting the following path:


Replace <user-id> with the user id of the user you want to impersonate.

While in impersonation "mode" the request.user object will have an
"_impersonate" attribute set to True. So if you wanted to check in your
templates or view, you just do something like...

{% if user._impersonate %} .... {% endif %}

You can reference this URL with reverse() or the {% url %} template tag
as 'impersonate-start'

To remove the impersonation, hit the following path:


You can reference this URL with reverse() or the {% url %} template tag
as 'impersonate-stop'

Copyright & Warranty
All documentation, libraries, and sample code are
Copyright 2011 Peter Sanchez <>. The library and
sample code are made available to you under the terms of the BSD license
which is contained in the included file, BSD-LICENSE.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-impersonate, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size django-impersonate-0.1.tar.gz (3.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page