Returns the redirect response for login/signup. Favors:
    - next param
    - LOGIN_REDIRECT_URL setting
    - homepage

def login_redirect(request):
    """
    Returns the redirect response for login/signup. Favors:
    - next param
    - LOGIN_REDIRECT_URL setting
    - homepage
    """
    ignorable_nexts = ("",)
    if "yacms.accounts" in settings.INSTALLED_APPS:
        from yacms.accounts import urls
        ignorable_nexts += (urls.SIGNUP_URL, urls.LOGIN_URL, urls.LOGOUT_URL)
    next = next_url(request) or ""
    if next in ignorable_nexts:
        next = settings.LOGIN_REDIRECT_URL
        if next == "/accounts/profile/":
            # Use the homepage if LOGIN_REDIRECT_URL is Django's defaut.
            next = get_script_prefix()
        else:
            try:
                next = reverse(next)
            except NoReverseMatch:
                pass
    return redirect(next)