'Displays the login form for the given HttpRequest.'

def login(self, request):

    from django.contrib.auth.models import User
    if (not request.POST.has_key(LOGIN_FORM_KEY)):
        if request.POST:
            message = _('Please    log    in    again,    because    your    session    has    expired.')
        else:
            message = ''
        return self.display_login_form(request, message)
    if (not request.session.test_cookie_worked()):
        message = _("Looks    like    your    browser    isn't    configured    to    accept    cookies.    Please    enable    cookies,    reload    this    page,    and    try    again.")
        return self.display_login_form(request, message)
    else:
        request.session.delete_test_cookie()
    username = request.POST.get('username', None)
    password = request.POST.get('password', None)
    user = authenticate(username=username, password=password)
    if (user is None):
        message = ERROR_MESSAGE
        if ((username is not None) and (u'@' in username)):
            try:
                user = User.objects.get(email=username)
            except (User.DoesNotExist, User.MultipleObjectsReturned):
                pass
            else:
                if user.check_password(password):
                    message = (_("Your    e-mail    address    is    not    your    username.    Try    '%s'    instead.") % user.username)
        return self.display_login_form(request, message)
    elif (user.is_active and user.is_staff):
        login(request, user)
        return http.HttpResponseRedirect(request.get_full_path())
    else:
        return self.display_login_form(request, ERROR_MESSAGE)
