Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dcramer/django-view-as
A Django middleware which allows you to view the site on behalf of a user.
https://github.com/dcramer/django-view-as
Last synced: about 2 months ago
JSON representation
A Django middleware which allows you to view the site on behalf of a user.
- Host: GitHub
- URL: https://github.com/dcramer/django-view-as
- Owner: dcramer
- License: apache-2.0
- Created: 2013-02-10T21:18:50.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2021-06-14T20:30:02.000Z (over 3 years ago)
- Last Synced: 2024-10-13T03:46:03.091Z (2 months ago)
- Language: Python
- Homepage:
- Size: 30.3 KB
- Stars: 81
- Watchers: 7
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
- starred-awesome - django-view-as - A Django middleware which allows you to view the site on behalf of a user. (Python)
README
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, 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 # F8If 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.