Browse Source

Workaround south changing INSTALLING_APPS during syncdb, breaking loaddata

Ralfp 12 years ago
parent
commit
02852baa4e

+ 1 - 1
misago/authn/fixtures.py

@@ -48,4 +48,4 @@ def load_fixtures():
 
 
 def update_fixtures():
-    update_settings_fixture(settings_fixtures)
+    update_settings_fixture(settings_fixtures)

+ 9 - 0
misago/settings_base.py

@@ -240,3 +240,12 @@ LOGGING = {
         },
     }
 }
+
+# Create copy of installed apps list
+# South overrides INSTALLED_APPS list with custom one
+# that doesn't contain apps without models when it
+# runs its own syncdb
+# Misago's loaddata command requires complete list of
+# installed apps in order to work correctly
+import copy
+INSTALLED_APPS_COMPLETE = copy.copy(INSTALLED_APPS)

+ 6 - 1
misago/setup/management/commands/loaddata.py

@@ -21,12 +21,16 @@ class Command(BaseCommand):
         )
     
     def handle(self, *args, **options):
+        if not options['quiet']:
+            self.stdout.write('\nLoading data from fixtures...')
+            
         fixture_data = {}
         for fixture in Fixture.objects.all():
             fixture_data[fixture.app_name] = fixture
         loaded = 0
         updated = 0
-        for app in settings.INSTALLED_APPS:
+        
+        for app in settings.INSTALLED_APPS_COMPLETE:
             if app in fixture_data:
                 if update_app_fixtures(app):
                     updated += 1
@@ -38,5 +42,6 @@ class Command(BaseCommand):
                     Fixture.objects.create(app_name=app)
                     if not options['quiet']:
                         self.stdout.write('\nLoading fixtures from %s' % app)
+        
         if not options['quiet']:
             self.stdout.write('\nLoaded %s fixtures and updated %s fixtures.\n' % (loaded, updated))