from django.contrib.auth import logout
from django.shortcuts import redirect

def Logout(request):
    def dispatch(self,request,*args, **kwargs):
        if request.user.is_authenticated:
            return super(Logout,self).dispatch(request, *args, **kwargs)
        else:
            return redirect('Index')
    logout(request)
    return redirect('Login')
