def login_required(function=None, redirect_field_name=REDIRECT_FIELD_NAME):
    actual_decorator = user_passes_test(
        lambda u: u.is_authenticated(),
        redirect_field_name=redirect_field_name
    )
    if function:
        return actual_decorator(function)
    return actual_decorator
Decorator for views that checks that the user is logged in, redirecting
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.2/django/contrib/auth/decorators.py/login_required