A Django middleware which allows you to view the site on behalf of a user.
Python
Switch branches/tags
Pull request Compare This branch is 1 commit ahead, 29 commits behind dcramer:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src/viewas
.gitignore
.travis.yml
LICENSE
MANIFEST.in
Makefile
README.rst
conftest.py
runtests.py
setup.cfg
setup.py

README.rst

django-view-as

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 and you'll see a new toolbar at the top of the page. Enter a username to change who you're viewing the site as.

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.