Skip to main content

A quick 'n' dirty Django app for switching between different users while testing

Project description

A quick ‘n’ dirty django app for switching between different users while testing.

  • “Quick and dirty”. Just include the middleware. That’s it!

  • Provides a select box with a list of users.

  • User list can be defined in settings or all users are loaded.

  • Works only when settings.DEBUG is True

Requirements

Django 1.2

Installation

To install the latest version:

pip install git+git://github.com/ikraftsoft/django-userswitch#egg=django-userswitch

It can also be installed from PyPI with pip or easy_install:

pip install django-userswitch
easy_install install django-userswitch

Setup & Usage

Add userswitch middleware to the MIDDLEWARE_CLASSES in settings.py after the default middlewares:

MIDDLEWARE_CLASSES = (
  'django.middleware.common.CommonMiddleware',
  'django.contrib.sessions.middleware.SessionMiddleware',
  'django.middleware.csrf.CsrfViewMiddleware',
  'django.contrib.auth.middleware.AuthenticationMiddleware',
  'django.contrib.messages.middleware.MessageMiddleware',
  ...
  'userswitch.middleware.UserSwitchMiddleware',
)

Optionally you can add USERSWITCH_OPTIONS dict to the settings.py:

USERSWITCH_OPTIONS = {
    'css_class': '',       # CSS class to be added to the switcher widget. Default='userswitch'.
    'css_inline': '',      # Inline css for the switcher widget, if any
    'content_types': (),   # a tuple of content-type for which to render switcher widget. Default = ('text/html', 'application/xhtml+xml')
    'auth_backend': '',    # Custom auth backend if any. Default = 'django.contrib.auth.backends.ModelBackend'
    'users': (),           # List of usernames(as strings) to be shown in the switcher widget. If its empty, all users are loaded.
}

Note: default value of css_inline option provides some basic absolute positioning. To change those either specify css_inline option manually or override position, top, right in the class specified in css_class with !important.

That’s All!

Project details


Download files

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

Source Distribution

django-userswitch-0.1.tar.gz (3.3 kB view details)

Uploaded Source

File details

Details for the file django-userswitch-0.1.tar.gz.

File metadata

File hashes

Hashes for django-userswitch-0.1.tar.gz
Algorithm Hash digest
SHA256 eaf7bd8bd062fe55cb545e49e5ef494d0c67a22badd148e981bf7506fe1d9c06
MD5 363a92c74cd69e10bdd25849c54d63ab
BLAKE2b-256 2a2a6e17cfdd0e19eaec52e8ec6d7168325c06687b3dd0d812b82a6a20ec40b1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page