Commits

Sverre Johansen committed 6e99ee7

Fixing fixture loading for Django 1.2

LoadInitialDataMigrator monkey patches django.models.get_app, so that
the loaddata management command only loads from the currently migrated
application. This breaks in Django 1.2 because it loads the method
differently.

Comments (0)

Files changed (1)

south/migration/migrators.py

 import traceback
 
 from django.core.management import call_command
+from django.core.management.commands import loaddata
 from django.db import models
 
 from south import exceptions
         # Override Django's get_apps call temporarily to only load from the
         # current app
         old_get_apps = models.get_apps
-        models.get_apps = lambda: [models.get_app(target.app_label())]
+        new_get_apps = lambda: [models.get_app(target.app_label())]
+        models.get_apps = new_get_apps
+        loaddata.get_apps = new_get_apps
         try:
             call_command('loaddata', 'initial_data', verbosity=self.verbosity)
         finally:
             models.get_apps = old_get_apps
+            loaddata.get_apps = old_get_apps
 
     def migrate_many(self, target, migrations):
         migrator = self._migrator