Ticket #6251: rename_project_dir.diff

File rename_project_dir.diff, 2.4 KB (added by Noam Raphael <spam.noam@…>, 17 years ago)
  • django/conf/project_template/settings.py

     
    11# Django settings for {{ project_name }} project.
    22
     3PROJECT_NAME = '{{ project_name }}'
     4
    35DEBUG = True
    46TEMPLATE_DEBUG = DEBUG
    57
  • django/core/management/__init__.py

     
    11import os
    22import sys
    33from optparse import OptionParser
    4 from imp import find_module
     4import imp
    55
    66import django
    77from django.core.management.base import BaseCommand, CommandError, handle_default_options
     
    4040    path = None
    4141    while parts:
    4242        part = parts.pop()
    43         f, path, descr = find_module(part, path and [path] or None)
     43        f, path, descr = imp.find_module(part, path and [path] or None)
    4444    return path
    4545
    4646def load_command_class(app_name, name):
     
    239239    Returns the project directory (assuming the passed settings module is
    240240    directly in the project directory).
    241241    """
    242     # Add this project to sys.path so that it's importable in the conventional
    243     # way. For example, if this file (manage.py) lives in a directory
    244     # "myproject", this code would add "/path/to/myproject" to sys.path.
    245     project_directory, settings_filename = os.path.split(settings_mod.__file__)
    246     if not project_directory:
    247         project_directory = os.getcwd()
    248     project_name = os.path.basename(project_directory)
     242    project_directory, settings_filename = os.path.split(
     243        os.path.abspath(settings_mod.__file__))
     244    try:
     245        project_name = settings_mod.PROJECT_NAME
     246    except AttributeError:
     247        project_name = os.path.basename(project_directory)
    249248    settings_name = os.path.splitext(settings_filename)[0]
    250     sys.path.append(os.path.join(project_directory, os.pardir))
    251     project_module = __import__(project_name, {}, {}, [''])
    252     sys.path.pop()
     249    project_module = imp.load_module(project_name, None, project_directory,
     250                                     ('', '', imp.PKG_DIRECTORY))
    253251
    254252    # Set DJANGO_SETTINGS_MODULE appropriately.
    255253    os.environ['DJANGO_SETTINGS_MODULE'] = '%s.%s' % (project_name, settings_name)
Back to Top