Commits

Konstantine Rybnikov  committed e94e0e8

add SOUTH_DATABASES setting to skip django_mongodb_engine databases

  • Participants
  • Parent commits 46c9fb7

Comments (0)

Files changed (2)

File docs/settings.rst

 (by your CI system or similar, in particlar) set this to ``True``.
 Defaults to ``False``.
 
+SOUTH_DATABASES
+---------------
+
+List of databases managed by South. If not set, all databases under
+``settings.DATABASES`` are taken.
+
 SOUTH_DATABASE_ADAPTER
 ----------------------
 

File south/db/__init__.py

 else:
     #### 1.2 or above ####
     # Loop over the defined databases, gathering up their engines
+    if hasattr(settings, 'SOUTH_DATABASES'):
+        south_databases = set(settings.SOUTH_DATABASES)
+    else:
+        south_databases = set(settings.DATABASES.keys())
     db_engines = dict([
         # Note we check to see if contrib.gis has overridden us.
         (alias, "south.db.%s" % engine_modules.get(db_settings['ENGINE'], None))
         for alias, db_settings in settings.DATABASES.items()
+        if alias in south_databases
     ])
     # Update with any overrides
     db_engines.update(getattr(settings, "SOUTH_DATABASE_ADAPTERS", {}))
         if engine is None:
             # They've used a backend we don't support
             sys.stderr.write(
-                (
-                    "There is no South database module for your database backend '%s'. " + \
-                    "Please either choose a supported database, check for " + \
-                    "SOUTH_DATABASE_ADAPTER[S] settings, " + \
-                    "or remove South from INSTALLED_APPS.\n"
-                ) % (settings.DATABASES[alias]['ENGINE'],)
-            )
+                ("There is no South database module for your database backend "
+                 "'%s'. Please either choose a supported database, check for "
+                 "SOUTH_DATABASES, SOUTH_DATABASE_ADAPTER[S] settings, "
+                 "or remove South from INSTALLED_APPS.\n") % (
+                    settings.DATABASES[alias]['ENGINE'],))
             sys.exit(1)
 
 # Now, turn that into a dict of <alias: south db module>
 except ImportError:
     # This error should only be triggered on 1.1 and below.
     sys.stderr.write(
-        (
-            "There is no South database module '%s' for your database. " + \
-            "Please either choose a supported database, check for " + \
-            "SOUTH_DATABASE_ADAPTER[S] settings, " + \
-            "or remove South from INSTALLED_APPS.\n"
-        ) % (module_name,)
-    )
+        ("There is no South database module '%s' for your database. "
+         "Please either choose a supported database, check for "
+         "SOUTH_DATABASES, SOUTH_DATABASE_ADAPTER[S] settings, "
+         "or remove South from INSTALLED_APPS.\n") % (module_name,))
     sys.exit(1)
-    
+
 # Finally, to make old migrations work, keep 'db' around as the default database
 db = dbs[DEFAULT_DB_ALIAS]