

def twitter_logout(request, redirect_field_name='next'):
    if request.user.is_authenticated():
        redirect_to = request.REQUEST.get(redirect_field_name, None)
        if ((not redirect_to) or (not is_safe_redirect(redirect_to))):
            try:
                redirect_to = reverse(settings.LOGOUT_REDIRECT_VIEW, args=[request.user.id])
            except NoReverseMatch:
                redirect_to = settings.LOGOUT_REDIRECT_URL
        logout(request)
    else:
        redirect_to = '/'
    return HttpResponseRedirect(redirect_to)

dataset/ETHPy150Open mdiep/django-twitter-users/twitter_users/views.py twitter_logout/original