diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2005-07-16 04:07:06 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2005-07-16 04:07:06 +0000 |
| commit | c0daa77ea642d62a1742f520e3208db6a531b61c (patch) | |
| tree | 13e2df840ad38e76664a54234545534ee0f54d08 /django/bin/django-admin.py | |
| parent | 635220c5cca60d512da5f41f99da54b4a4acca3b (diff) | |
django-admin.py startproject now automatically points admin TEMPLATE_DIRS setting at the location of the default admin templates
git-svn-id: http://code.djangoproject.com/svn/django/trunk@95 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/bin/django-admin.py')
| -rw-r--r-- | django/bin/django-admin.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/django/bin/django-admin.py b/django/bin/django-admin.py index ca4eb99e51..28c21fb1cb 100644 --- a/django/bin/django-admin.py +++ b/django/bin/django-admin.py @@ -13,7 +13,10 @@ MODULE_TEMPLATE = ''' {%% if perms.%(app)s.%(addperm)s or perms.%(app)s.%(cha APP_ARGS = '[app app ...]' +# Use django.__path__[0] because we don't know which directory django into +# which has been installed. PROJECT_TEMPLATE_DIR = django.__path__[0] + '/conf/%s_template' +ADMIN_TEMPLATE_DIR = django.__path__[0] + '/conf/admin_templates' def _get_packages_insert(app_label): return "INSERT INTO packages (label, name) VALUES ('%s', '%s');" % (app_label, app_label) @@ -331,6 +334,14 @@ def _start_helper(app_or_project, name, directory, other_name=''): def startproject(project_name, directory): "Creates a Django project for the given project_name in the given directory." _start_helper('project', project_name, directory) + # Populate TEMPLATE_DIRS for the admin templates, based on where Django is + # installed. + settings_file = os.path.join(directory, project_name, 'settings/admin.py') + settings_contents = open(settings_file, 'r').read() + fp = open(settings_file, 'w') + settings_contents = re.sub(r'(?s)\b(TEMPLATE_DIRS\s*=\s*\()(.*?)\)', "\\1\n '%s',\\2)" % ADMIN_TEMPLATE_DIR, settings_contents) + fp.write(settings_contents) + fp.close() startproject.help_doc = "Creates a Django project directory structure for the given project name in the current directory." startproject.args = "[projectname]" |
