Commits

Anonymous committed 1125083

Do imports correctly, so apps not on pythonpath directly work.

Comments (0)

Files changed (1)

     return app.__name__.split('.')[-2]
 
 
+def get_app_fullname(app):
+    """
+    Returns the full python name of an app - e.g. django.contrib.auth
+    """
+    return app.__name__[:-7]
+
+
 def short_from_long(app):
     return app.split(".")[-1]
 
     if isinstance(app, (str, unicode)):
         # If it's a string, use the models module
         app = models.get_app(app)
-    app_name = '.'.join( app.__name__.split('.')[0:-1] )
-    mod = __import__(app_name, {}, {}, ['migrations'])
+    mod = __import__(get_app_fullname(app), {}, {}, ['migrations'])
     if hasattr(mod, 'migrations'):
         return getattr(mod, 'migrations')
 
     Returns the migration class implied by 'name'.
     """
     if not isinstance(app, (str, unicode)):
-        app = get_app_name(app)
+        app = get_app_fullname(app)
     module = __import__(app + ".migrations." + name, '', '', ['Migration'])
     return module.Migration
 
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.