Skip to content

Commit

Permalink
[1.0.X] Fixed ##9842: allow imports of apps that use settings in __in…
Browse files Browse the repository at this point in the history
…it__.py files.

Backport of r9843 from trunk.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9901 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
jacobian committed Feb 24, 2009
1 parent 734376f commit 3550aa2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions django/core/management/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 3550aa2

Please sign in to comment.