﻿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
20344	Allow django to discover management commands from namespace packages.	James Reynolds	nobody	"Certain third party package maintainers may desire to have their apps in a namespace package. If those packages contain management commands, Django might not be able to discover them.

For example, if you have a namespace package that looks something like this:

{{{
site-packages/namespace/space/package1
site-packages/namespace/space/package2
}}}

Django will not be able to discover the packages during management registration (and in fact, could raise errors depending on the management command). If Django fails to locate a package during this process, it fails silently, which could be confusing for some developers.

Package discovery fails for one primary reason:
* 1. Namespace and namespace/space directories above do not necessarily need __init__.py files located in their directory.

So for demonstration, import namespace.space.package1 works while import namspace and import namespace.space will not work.

The workaround here is just to allow for a direct import (if it succeeds) and take the path from that module for django to register the management command.

This solution should work in most situations where the namespace package is installed ""normally"" and can be found in the python path.

Branch is here: https://github.com/eire1130/django/tree/namespace_management_imports
Commit is here: https://github.com/eire1130/django/commit/3d495addc567e617eaef2b107fea6edaad161288

If approved, I will send the pull request."	Bug	closed	Core (Management commands)	dev	Normal	duplicate		bhuztez@…	Unreviewed	0	0	0	0	0	0
