﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
18179	Management can't load custom commands when separately packaged apps share a common base module	nOw2	nobody	"django.core.management.find_management_module() loads custom commands for manage.py by finding the path of the module and examining file directly.

This fails when apps are within packages that share a common base name, but where the files are NOT in the same directories, example:

 * app 1: company.division.project_a.app1 stored in path `packages/company.subdivision.project_a.app1`
 * app 2: company.division.project_b.app2 stored in path `packages/company.subdivision.project_b.app2`

Custom commands in app 2 will not be found.

A code trace from pdb follows. Excuse the rather complicated example, but this is from a genuine problem and only the modules names have been changed.

{{{
> site-packages/django/core/management/__init__.py(43)find_management_module()
-> parts.append('management')
(Pdb) parts
['company', 'subdivision', 'project_b', 'app2']

. . .

> site-packages/django/core/management/__init__.py(62)find_management_module()
-> f, path, descr = imp.find_module(part, path and [path] or None)
(Pdb) 
ImportError: 'No module named project_b'
> site-packages/django/core/management/__init__.py(62)find_management_module()
-> f, path, descr = imp.find_module(part, path and [path] or None)
(Pdb) l
 57  	        if os.path.basename(os.getcwd()) != part:
 58  	            raise e
 59  	
 60  	    while parts:
 61  	        part = parts.pop()
 62  ->	        f, path, descr = imp.find_module(part, path and [path] or None)
 63  	    return path
 64  	
 65  	def load_command_class(app_name, name):
 66  	    """"""
 67  	    Given a command name and an application name, returns the Command
(Pdb) part
'project_b'
(Pdb) path
'packages/company.subdivision.project_a.app1/company/subdivision'
}}}

Issue was found in 1.3.1 but the code appears the same in the current trunk version:
https://code.djangoproject.com/browser/django/trunk/django/core/management/__init__.py?rev=17842#L60"	Bug	closed	Core (Management commands)	1.4	Normal	invalid			Unreviewed	0	0	0	0	0	0
