Commits

Andrew Godwin committed 6ce9576

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

Comments (0)

Files changed (1)

south/management/commands/syncdb.py

 from django.core.management.color import no_style
 from django.utils.datastructures import SortedDict
 from django.core.management.commands 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 = []
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.