Helper method. Generic login with username and password.

def login_generic(request, username, password):
        """Helper method. Generic login with username and password."""
        user = authenticate(username=username, password=password)
        if user is not None and user.is_active:
            login(request, user)
            return True
        return False