﻿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
10966	Management module imports project_module, considered evil	Patryk Zawadzki	nobody	"I think Django's {{{core.management.setup_environ}}} should stop trying to import the project dir as if it was a module.

Currently lines 337-341 read:
{{{
# Import the project module. We add the parent directory to PYTHONPATH to
# avoid some of the path errors new users can have.
sys.path.append(os.path.join(project_directory, os.pardir))
project_module = import_module(project_name)
sys.path.pop()
}}}

There is no explanation as to why it's useful to treat the project as a module. Also it assumes that:

 * there is no and will never be a python module using the same name in any of the current {{{sys.path}}} directories;
 * the directory name is a valid python module

I see no value in treating a mere container dir as a module. If there is one, it could be clarified in the comment, currently it just states what the code does while not really explaining why.

I actually have projects where the dir only contains settings.py and an empty {{{__init__.py}}} just to keep Django from crashing. If you don't import apps using your project name as a prefix, the {{{__init__.py}}} file is useless and you should be free to use any directory name you want. If you do use the project prefix, Python will already happily parse the top-level {{{__init__.py}}} for you and I see no point in importing it earlier in {{{core.management}}}."		closed	Core (Other)	dev		wontfix		Gonzalo Saavedra	Unreviewed	1	1	1	0	0	0
