Andrew Godwin avatar Andrew Godwin committed 0f7c6cf

Thanks to peritus on IRC, a way to make mocks for apps which have since vanished.

Comments (0)

Files changed (1)

 
 from django.db import models
 from django.db.models.loading import cache
+from django.core.exceptions import ImproperlyConfigured
 
 from south.db import db
 from south.utils import ask_for_it_by_name
     
     def make_meta(self, app, model, data, stub=False):
         "Makes a Meta class out of a dict of eval-able arguments."
-        results = {}
+        results = {'app_label': app}
         for key, code in data.items():
             # Some things we never want to use.
             if key in ["_bases"]:
         
         # Find the app in the Django core, and get its module
         more_kwds = {}
-        app_module = models.get_app(app)
-        more_kwds['__module__'] = app_module.__name__
+        try:
+            app_module = models.get_app(app)
+            more_kwds['__module__'] = app_module.__name__
+        except ImproperlyConfigured:
+            # The app this belonged to has vanished, but thankfully we can still
+            # make a mock model, so ignore the error.
+            more_kwds['__module__'] = '_south_mock'
         
         more_kwds['Meta'] = meta
         
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.