Commits

Andrew Godwin  committed 03a24b0
  • Participants
  • Parent commits 8346768

Comments (0)

Files changed (2)

File south/hacks/django_1_0.py

 
 class Hacks:
     
-    def set_installed_apps(self, apps, preserve_models=False):
+    def set_installed_apps(self, apps):
         """
         Sets Django's INSTALLED_APPS setting to be effectively the list passed in.
         """
             apps,
             settings.INSTALLED_APPS,
         )
-        self._redo_app_cache(preserve_models=preserve_models)
+        self._redo_app_cache()
     
     
     def reset_installed_apps(self):
         self._redo_app_cache()
     
     
-    def _redo_app_cache(self, preserve_models=False):
+    def _redo_app_cache(self):
         """
         Used to repopulate AppCache after fiddling with INSTALLED_APPS.
         """
         cache.handled = set() if django.VERSION >= (1, 6) else {}
         cache.postponed = []
         cache.app_store = SortedDict()
-        if not preserve_models:
-            cache.app_models = SortedDict()
+        cache.app_models = SortedDict()
         cache.app_errors = {}
         cache._populate()
     

File south/migration/migrators.py

 from django.core.management import call_command
 from django.core.management.commands import loaddata
 from django.db import models
-from django.conf import settings
 
 import south.db
 from south import exceptions
 from south.models import MigrationHistory
 from south.signals import ran_migration
 from south.utils.py3 import StringIO
-from south.hacks import hacks
 
 
 class Migrator(object):
             print(" - Loading initial data for %s." % target.app_label())
         # Override Django's get_apps call temporarily to only load from the
         # current app
-        hacks.set_installed_apps([ia for ia in settings.INSTALLED_APPS if ia.split(".")[-1] == target.app_label()], preserve_models=True)
+        old_get_apps = models.get_apps
+        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, database=db)
         finally:
-            hacks.reset_installed_apps()
+            models.get_apps = old_get_apps
+            loaddata.get_apps = old_get_apps
 
     def migrate_many(self, target, migrations, database):
         migrator = self._migrator