Skip to content

Commit

Permalink
Allow django to discover management commands from namespace packages.
Browse files Browse the repository at this point in the history
  • Loading branch information
eire1130 committed May 2, 2013
1 parent 9f7a01e commit 3d495ad
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions django/core/management/__init__.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -52,11 +52,21 @@ def find_management_module(app_name):
# testproject isn't in the path. When looking for the management # testproject isn't in the path. When looking for the management
# module, we need look for the case where the project name is part # 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. # of the app_name but the project directory itself isn't on the path.

try: try:
f, path, descr = imp.find_module(part, path) f, path, descr = imp.find_module(part, path)
except ImportError as e: except ImportError as e:
if os.path.basename(os.getcwd()) != part: try:
raise e 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: else:
if f: if f:
f.close() f.close()
Expand Down

0 comments on commit 3d495ad

Please sign in to comment.