Skip to content

Instantly share code, notes, and snippets.

@nandak522
Created November 25, 2009 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nandak522/242439 to your computer and use it in GitHub Desktop.
Save nandak522/242439 to your computer and use it in GitHub Desktop.
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment