Ticket #6251: rename_project_dir.diff
File rename_project_dir.diff, 2.4 KB (added by , 17 years ago) |
---|
-
django/conf/project_template/settings.py
1 1 # Django settings for {{ project_name }} project. 2 2 3 PROJECT_NAME = '{{ project_name }}' 4 3 5 DEBUG = True 4 6 TEMPLATE_DEBUG = DEBUG 5 7 -
django/core/management/__init__.py
1 1 import os 2 2 import sys 3 3 from optparse import OptionParser 4 from imp import find_module 4 import imp 5 5 6 6 import django 7 7 from django.core.management.base import BaseCommand, CommandError, handle_default_options … … 40 40 path = None 41 41 while parts: 42 42 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) 44 44 return path 45 45 46 46 def load_command_class(app_name, name): … … 239 239 Returns the project directory (assuming the passed settings module is 240 240 directly in the project directory). 241 241 """ 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) 249 248 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)) 253 251 254 252 # Set DJANGO_SETTINGS_MODULE appropriately. 255 253 os.environ['DJANGO_SETTINGS_MODULE'] = '%s.%s' % (project_name, settings_name)