summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2008-08-08 12:27:40 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2008-08-08 12:27:40 +0000
commit196b2827759da3c80617418cbcdcb51f2d8ce1bc (patch)
tree88a0ff4c7b82f7d83d4aafc2f0aef5a2ebef8d0f /django
parent7b4b1309d92feab417e48d391482f81e6ba683ee (diff)
Fixed #5825 -- Modified the custom command loader to allow for explicit specification of the project name, even if the project directory isn't in the python path. This brings custom command loading into alignment with application loading. Thanks to jdetaeye@frepple.com for the original report, and to abozanich for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8227 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/core/management/__init__.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py
index 5e01ccbbe9..1e8017e77f 100644
--- a/django/core/management/__init__.py
+++ b/django/core/management/__init__.py
@@ -37,7 +37,21 @@ def find_management_module(app_name):
parts = app_name.split('.')
parts.append('management')
parts.reverse()
+ part = parts.pop()
path = None
+
+ # When using manage.py, the project module is added to the path,
+ # loaded, then removed from the path. This means that
+ # testproject.testapp.models can be loaded in future, even if
+ # 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 = find_module(part,path)
+ except ImportError,e:
+ if os.path.basename(os.getcwd()) != part:
+ raise e
+
while parts:
part = parts.pop()
f, path, descr = find_module(part, path and [path] or None)