Skip to main content

A simple middleware which allows a superuser to view the site on behalf of another user.

This idea originated within Disqus, and has served quite well in helping debug user problems.

Install

Install the package:

pip install django-view-as

Add the middleware:

MIDDLEWARE_CLASSES = (
        'viewas.middleware.ViewAsMiddleware',
)

Register the application within INSTALLED_APPS:

INSTALLED_APPS = (
        'django.contrib.auth',
        'django.contrib.sessions',
        'viewas',
)

Make sure the application loader is available for templates:

TEMPLATE_LOADERS = (
        'django.template.loaders.app_directories.Loader',
)

Usage

Load any page with an html response type, hit the tilda key (~), and you’ll see a new toolbar at the bottom of the page. Enter a username to change who you’re viewing the site as.

Configure the menu toggle key

The following configuration option could be set in your settings.py to change the default keystroke to toggle the “View as” menu. Its value is the javascript key number that will be matched in the keydown event handler.

VIEWAS_TOGGLE_KEY = 119  # F8

If you need more complex behavior (such as not binding based on the superuser attribute), check out the source the middleware is designed to be extensibile.

Release files for django-view-as 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-view-as 0.5.0
File Size Uploaded
django-view-as-0.5.0.tar.gz 8.2 kB Details

Release files / django-view-as-0.5.0.tar.gz

Download URL django-view-as-0.5.0.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e9fa282a7f18a1477998c5ccb075037e5b5fa95a7e557a65a77dddf9141a5e2b
BLAKE2b-256 checksum
How to use checksums
8e038942aee2d10cb88fb1330c20b7a659ea30edfd763297fa5b0478c2be2973
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.5.0 This release

1 release file

0.4.0

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page