def handle(self, name, cursor=None, **options):
     if name in settings.MULTISCHEMA_ALIAS_EXCLUDE:
         raise CommandError('%s is on the exclude list' % name)
     cursor = cursor or connections[options.get('database', DEFAULT_DB_ALIAS)].cursor()
     
     if not namespace.exists(name):
         namespace.create(name, cursor=cursor)
         transaction.commit_unless_managed()
def create_namespace_if_not_exist(sender, connection, **kwargs):
    connected_alias = get_connection_alias(connection)
    
    if connected_alias and connected_alias not in settings.MULTISCHEMA_ALIAS_EXCLUDE:
        ns = alias_lookup(connected_alias)
        
        if ns and not namespace.exists(ns):
            cursor = connection.cursor()
            
            with transaction.commit_on_success(using=connected_alias):
                namespace.create(ns, cursor=cursor)