summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-09-06 22:14:40 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-09-06 22:14:40 +0000
commitf46402bc90e85f610d8ed564b35651e8244337b3 (patch)
treed874cb8b01752242c4287f41463daab7668f46d3
parent93010c75f2b6889387107285f28230b483d0527d (diff)
Made 'django-admin.py init' more robust
git-svn-id: http://code.djangoproject.com/svn/django/trunk@632 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/management.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/django/core/management.py b/django/core/management.py
index 3b6fe36378..21e3f7c78c 100644
--- a/django/core/management.py
+++ b/django/core/management.py
@@ -286,19 +286,23 @@ get_admin_index.args = APP_ARGS
def init():
"Initializes the database with auth and core."
- from django.core import db, meta
- auth = meta.get_app('auth')
- core = meta.get_app('core')
try:
+ from django.core import db, meta
+ auth = meta.get_app('auth')
+ core = meta.get_app('core')
cursor = db.db.cursor()
for sql in get_sql_create(core) + get_sql_create(auth) + get_sql_initial_data(core) + get_sql_initial_data(auth):
cursor.execute(sql)
cursor.execute("INSERT INTO %s (domain, name) VALUES ('mysite.com', 'My Django site')" % core.Site._meta.db_table)
except Exception, e:
- sys.stderr.write("Error: The database couldn't be initialized. Here's the full exception:\n%s\n" % e)
- db.db.rollback()
+ sys.stderr.write("Error: The database couldn't be initialized.\n%s\n" % e)
+ try:
+ db.db.rollback()
+ except UnboundLocalError:
+ pass
sys.exit(1)
- db.db.commit()
+ else:
+ db.db.commit()
init.args = ''
def install(mod):