Ticket #10966: project_module_optional.2.patch
File project_module_optional.2.patch, 1.4 KB (added by , 15 years ago) |
---|
-
django/core/management/__init__.py
331 331 if settings_name.endswith("$py"): 332 332 settings_name = settings_name[:-3] 333 333 334 # Decide whether to treat the project directory as a Python package. 335 project_is_package = '__init__.py' in os.listdir(project_directory) 336 334 337 # Set DJANGO_SETTINGS_MODULE appropriately. 335 338 if original_settings_path: 336 os.environ['DJANGO_SETTINGS_MODULE'] = original_settings_path 339 envvar = original_settings_path 340 elif project_is_package: 341 envvar = '%s.%s' % (project_name, settings_name) 337 342 else: 338 os.environ['DJANGO_SETTINGS_MODULE'] = '%s.%s' % (project_name, settings_name) 343 envvar = settings_name 344 os.environ['DJANGO_SETTINGS_MODULE'] = envvar 339 345 340 346 # Import the project module. We add the parent directory to PYTHONPATH to 341 347 # avoid some of the path errors new users can have. 342 sys.path.append(os.path.join(project_directory, os.pardir)) 343 project_module = import_module(project_name) 344 sys.path.pop() 348 if project_is_package: 349 sys.path.append(os.path.join(project_directory, os.pardir)) 350 project_module = import_module(project_name) 351 sys.path.pop() 345 352 346 353 return project_directory 347 354