Login as Any Site user

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
def login_using_email(request, email):
    '''DONT EVER USE this method for normal purposes. This is only there, for debugging specific problems related to users'''
    from django.contrib.auth import get_backends
    backend = get_backends()[0]
    from django.contrib.auth.models import User
    user = User.objects.get(email=email)
    user.backend = "%s.%s" % (backend.__module__, backend.__class__.__name__)
    from django.contrib.auth import login as django_login
    django_login(request, user)
    #set_any_extra_session_variables(request)

More like this

  1. Specify a manager for the Admin by kylefox 3 years, 12 months ago
  2. All Imports Checker by madhav.bnk 2 years, 2 months ago
  3. Using Templates to Send E-Mails by rpoulton 4 years, 11 months ago
  4. Update only selected model fields by jcrocholl 4 years, 2 months ago
  5. Clear session data on login and logout by jb0t 3 years, 10 months ago

Comments

leosh (on November 30, 2009):

Check out an 'su' view: http://copiousfreetime.blogspot.com/2006/12/django-su.html

It does the same thing as this snippet but with wrapping and explanations.

#

KomarovPetr26 (on December 2, 2011):

ВИП-сваха для брака с богачом

#

ZaharovMatvej21 (on January 7, 2012):

прокат, аренда аттракционов Киев, большой выбор

#

(Forgotten your password?)