Permalink
Browse files

Allow django to discover management commands from namespace packages.

  • Loading branch information...
1 parent 9f7a01e commit 3d495addc567e617eaef2b107fea6edaad161288 @eire1130 committed May 2, 2013
Showing with 12 additions and 2 deletions.
  1. +12 −2 django/core/management/__init__.py
@@ -52,11 +52,21 @@ def find_management_module(app_name):
# testproject isn't in the path. When looking for the management
# module, we need look for the case where the project name is part
# of the app_name but the project directory itself isn't on the path.
+
try:
f, path, descr = imp.find_module(part, path)
except ImportError as e:
- if os.path.basename(os.getcwd()) != part:
- raise e
+ try:
+ from importlib import import_module
+ module=import_module(app_name)
+ except ImportError,e:
+ if os.path.basename(os.getcwd()) != part:
+ raise e
+ else:
+ paths = module.__path__
+ if len(paths) > 0:
+ path = paths[0]
+ parts = ['management']
else:
if f:
f.close()

0 comments on commit 3d495ad

Please sign in to comment.