def not_authenticated(func):
 def decorated(request, *args, **kwargs):
  if request.user.is_authenticated():
   next = request.GET.get('next', '/')
   return HttpResponseRedirect(next)
  return func(request, *args, **kwargs)
 return decorated

def not_authenticated ( func ) : def decorated ( request , * args , ** kwargs ) : if request . user . is_authenticated ( ) : next = request . GET . get ( 'next' , '/' ) return HttpResponseRedirect ( next ) return func ( request , * args , ** kwargs ) return decorated
decorator that redirect user to next page if he is already logged .