def login_forbidden(view_func, template_name='login_forbidden.html', status=403):
 @wraps(view_func)
 def _checklogin(request, *args, **kwargs):
  if (not request.user.is_authenticated()):
   return view_func(request, *args, **kwargs)
  return render(request, template_name, status=status)
 return _checklogin

def login_forbidden ( view_func , template_name = 'login_forbidden.html' , status = 403 ) : @ wraps ( view_func ) def _checklogin ( request , * args , ** kwargs ) : if ( not request . user . is_authenticated ( ) ) : return view_func ( request , * args , ** kwargs ) return render ( request , template_name , status = status ) return _checklogin
only allow anonymous users to access this view .