def require_superuser(handler):
 def require_superuser_wrapper_fn(request, *args, **kwargs):
  if getattr(request.user, 'is_superuser', False):
   return handler(request, *args, **kwargs)
  else:
   raise PermissionDenied(_('You must be logged in as a superuser to access this endpoint.'))
 return require_superuser_wrapper_fn

def require_superuser ( handler ) : def require_superuser_wrapper_fn ( request , * args , ** kwargs ) : if getattr ( request . user , 'is_superuser' , False ) : return handler ( request , * args , ** kwargs ) else : raise PermissionDenied ( _ ( 'You must be logged in as a superuser to access this endpoint.' ) ) return require_superuser_wrapper_fn
level 4: require a django admin *** note: not yet used .