Andrew Godwin  committed 6ce9576

Fix #511: South doesn't import management modules during syncdb.

  • Participants
  • Parent commits 3038690
  • Branches default

Comments (0)

Files changed (1)

File south/management/commands/

 from import no_style
 from django.utils.datastructures import SortedDict
 from import syncdb
+from django.utils.importlib import import_module
 from django.conf import settings
 from django.db import models
 from django.db.models.loading import cache
     help = "Create the database tables for all apps in INSTALLED_APPS whose tables haven't already been created, except those which use migrations."
     def handle_noargs(self, migrate_all=False, **options):
+        # Import the 'management' module within each installed app, to register
+        # dispatcher events.
+        # This is copied from Django, to fix bug #511.
+        for app_name in settings.INSTALLED_APPS:
+            try:
+                import_module('.management', app_name)
+            except ImportError, exc:
+                msg = exc.args[0]
+                if not msg.startswith('No module named') or 'management' not in msg:
+                    raise
         # Work out what uses migrations and so doesn't need syncing
         apps_needing_sync = []
         apps_migrated = []