From c0daa77ea642d62a1742f520e3208db6a531b61c Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Sat, 16 Jul 2005 04:07:06 +0000 Subject: [PATCH] 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 --- django/bin/django-admin.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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]"