GithubHelp home page GithubHelp logo

mkching / django-su Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adamcharnock/django-su

0.0 1.0 0.0 122 KB

Login as any user from the Django admin interface, then switch back when done

License: MIT License

Python 87.67% HTML 12.33%

django-su's Introduction

django-su

Login as any user from the Django admin interface, then switch back when done

Authored by Adam Charnock, and some great contributors.

image

image

image

image

Installation

  1. Either checkout django_su from GitHub, or install using pip :
pip install django-su
  1. Add django_su to your INSTALLED_APPS. Make sure you put it before django.contrib.admin :
INSTALLED_APPS = (
    ...
    'django_su',  # must be before ``django.contrib.admin``
    'django.contrib.admin',
)
  1. Add SuBackend to AUTHENTICATION_BACKENDS :
AUTHENTICATION_BACKENDS = (
    ...
    'django_su.backends.SuBackend',
)
  1. Update your urls.py file :
urlpatterns = patterns('',
    url(r'^su/', include('django_su.urls')),
    ...
)

And that should be it!

Please see example application. This application is used to manually test the functionalities of this package. This also serves as a good example.

You need only Django 1.4 or above to run that. It might run on older versions but that is not tested.

If you install these two apps the enhance user experience:

Note that django ajax selects requires the following settings:

AJAX_LOOKUP_CHANNELS = {'django_su':  dict(model='auth.user', search_field='username')}

Configuration (optional)

There are various optional configuration options you can set in your settings.py

# URL to redirect after the login.
# Default: "/"
SU_LOGIN_REDIRECT_URL = "/" 

# URL to redirect after the logout.
# Default: "/"
SU_LOGOUT_REDIRECT_URL = "/dashboard/"

# A function to specify the perms that the user must have can use django_su
# Default: None
SU_LOGIN_CALLBACK = "example.utils.su_login_callback"

# A function to override the django.contrib.auth.login(request, user)
# function so you can set session data, etc.
# Default: None
SU_CUSTOM_LOGIN_ACTION = "example.utils.custom_login"

Usage

Go and view a user in the admin interface and look for a new "Login as" button in the top right.

Once you have su'ed into a user, you can get exit back into your original user by navigating to /su/ in your browser.

Credits

This app was put together by Adam Charnock, but was largely based on ideas, code and comments at:

django-su is packaged using seed.

django-su's People

Contributors

adamcharnock avatar aljosa avatar bashu avatar bradbeattie avatar bufke avatar dfrdmn avatar goinnn avatar johnsmclay avatar katzj avatar lagg avatar leknarf avatar somewes avatar thisboyiscrazy avatar wolever avatar yakky avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.