Django

Code

Changeset 95

Show
Ignore:
Timestamp:
07/15/05 23:07:06 (3 years ago)
Author:
adrian
Message:

django-admin.py startproject now automatically points admin TEMPLATE_DIRS setting at the location of the default admin templates

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/bin/django-admin.py

    r93 r95  
    1414APP_ARGS = '[app app ...]' 
    1515 
     16# Use django.__path__[0] because we don't know which directory django into 
     17# which has been installed. 
    1618PROJECT_TEMPLATE_DIR = django.__path__[0] + '/conf/%s_template' 
     19ADMIN_TEMPLATE_DIR = django.__path__[0] + '/conf/admin_templates' 
    1720 
    1821def _get_packages_insert(app_label): 
     
    332335    "Creates a Django project for the given project_name in the given directory." 
    333336    _start_helper('project', project_name, directory) 
     337    # Populate TEMPLATE_DIRS for the admin templates, based on where Django is 
     338    # installed. 
     339    settings_file = os.path.join(directory, project_name, 'settings/admin.py') 
     340    settings_contents = open(settings_file, 'r').read() 
     341    fp = open(settings_file, 'w') 
     342    settings_contents = re.sub(r'(?s)\b(TEMPLATE_DIRS\s*=\s*\()(.*?)\)', "\\1\n    '%s',\\2)" % ADMIN_TEMPLATE_DIR, settings_contents) 
     343    fp.write(settings_contents) 
     344    fp.close() 
    334345startproject.help_doc = "Creates a Django project directory structure for the given project name in the current directory." 
    335346startproject.args = "[projectname]"