mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
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
This commit is contained in:
parent
635220c5cc
commit
c0daa77ea6
@ -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]"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user