Django

Code

Changeset 1556

Show
Ignore:
Timestamp:
12/05/05 23:53:31 (4 years ago)
Author:
adrian
Message:

Added conf/project_template/manage.py, which is a light wrapper around django-admin.py that gets installed in each project with 'startproject'. It takes care of the PYTHONPATH and DJANGO_SETTINGS_MODULE business automatically.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/management.py

    r1555 r1556  
    961961        if action not in NO_SQL_TRANSACTION: 
    962962            print "COMMIT;" 
     963 
     964def execute_manager(settings_mod): 
     965    # Add this project to sys.path so that it's importable in the conventional 
     966    # way. For example, if this file (manage.py) lives in a directory 
     967    # "myproject", this code would add "/path/to/myproject" to sys.path. 
     968    project_directory = os.path.dirname(settings_mod.__file__) 
     969    project_name = os.path.basename(project_directory) 
     970    sys.path.append(os.path.join(project_directory, '..')) 
     971    project_module = __import__(project_name, '', '', ['']) 
     972    sys.path.pop() 
     973 
     974    # Set DJANGO_SETTINGS_MODULE appropriately. 
     975    os.environ['DJANGO_SETTINGS_MODULE'] = '%s.settings' % project_name 
     976 
     977    # Remove the "startproject" command from the action_mapping, because that's 
     978    # a django-admin.py command, not a manage.py command. 
     979    action_mapping = DEFAULT_ACTION_MAPPING.copy() 
     980    del action_mapping['startproject'] 
     981 
     982    # Run the django-admin.py command. 
     983    execute_from_command_line(action_mapping)