Plain is headed towards 1.0! Subscribe for development updates →

plain.impersonate

See what your users see.

A key feature for providing customer support is to be able to view the site through their account. With impersonate installed, you can impersonate a user by finding them in the Django admin and clicking the "Impersonate" button.

Then with the staff toolbar enabled, you'll get a notice of the impersonation and a button to exit:

Installation

To impersonate users, you need the app, middleware, and URLs:

# settings.py
INSTALLED_PACKAGES = INSTALLED_PACKAGES + [
  "plain.staff.impersonate",
]

MIDDLEWARE = MIDDLEWARE + [
  "plain.staff.impersonate.ImpersonateMiddleware",
]
# urls.py
urlpatterns = [
    # ...
    path("impersonate/", include("plain.staff.impersonate.urls")),
]

Settings

By default, all staff users can impersonate other users.

# settings.py
IMPERSONATE_ALLOWED = lambda user: user.is_staff
 1from . import settings
 2
 3
 4def can_be_impersonator(user):
 5    return settings.IMPERSONATE_ALLOWED(user)
 6
 7
 8def can_impersonate_user(impersonator, target_user):
 9    if not can_be_impersonator(impersonator):
10        return False
11
12    # You can't impersonate staff users
13    if target_user.is_staff:
14        return False
15
16    return True