Giter VIP home page Giter VIP logo

django-su's Introduction

https://badge.fury.io/py/django-su.png https://pypip.in/d/django-su/badge.png

Installation

Step 1: Settings

Add django_su to INSTALLED_APPS. Make sure you put it before django.contrib.admin.

Next add the django-su authentication backend:

AUTHENTICATION_BACKENDS = (
    # Standard Django auth
    "django.contrib.auth.backends.ModelBackend",
    # django-su auth
    "django_su.backends.SuBackend",
)

Step 2: urls.py

Add this to your root urls.py file:

url(r"^su/", include("django_su.urls")),

And that should be it!

Step 3: Install other eggs (optional, but recommended)

If you install these two eggs 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')}

Step 4: Customize django_su (optional)

In your settings you can configure:

  • SU_REDIRECT_LOGIN: URL to redirect after the login. By default is "/"
  • SU_REDIRECT_EXIT: URL to redirect after the logout. By default is "/"
  • SU_LOGIN: A function to specify the perms that the user must have can use django_su
  • SU_CUSTOM_LOGIN_ACTION: A function to override the django.contrib.auth.login(request, user) function so you can set session data, etc.

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 bradbeattie avatar bufke avatar dfrdmn avatar goinnn avatar johnsmclay avatar katzj avatar lagg avatar leknarf avatar somewes avatar thisboyiscrazy avatar wolever avatar

Watchers

 avatar  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.