From fd28d04c39f83672f674aa2d83557db36a70b4b5 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Mon, 16 Feb 2009 21:03:09 +0000 Subject: [PATCH] Merge branch 'master' into upstream-trunk git-svn-id: http://code.djangoproject.com/svn/django/trunk@9843 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/management/__init__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py index c4396d2976..ec5ea19c98 100644 --- a/django/core/management/__init__.py +++ b/django/core/management/__init__.py @@ -319,15 +319,18 @@ def setup_environ(settings_mod, original_settings_path=None): if settings_name.endswith("$py"): settings_name = settings_name[:-3] - sys.path.append(os.path.join(project_directory, os.pardir)) - project_module = __import__(project_name, {}, {}, ['']) - sys.path.pop() - # Set DJANGO_SETTINGS_MODULE appropriately. if original_settings_path: os.environ['DJANGO_SETTINGS_MODULE'] = original_settings_path else: os.environ['DJANGO_SETTINGS_MODULE'] = '%s.%s' % (project_name, settings_name) + + # 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__(project_name, {}, {}, ['']) + sys.path.pop() + return project_directory def execute_from_command_line(argv=None):