summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-03-11 22:37:23 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-03-11 22:40:13 +0100
commita50e0c9fdc563bba2ea2e14115c412100f2fd8b2 (patch)
tree90d9580a48d192a9ed45521117402f5725f89e6b
parentbc7a10299f7ad7f468fa78d5990b7b545d4d599d (diff)
Fixed a refactoring error in ba5138b1.
Thanks Florian for tracing the error.
-rw-r--r--django/core/management/commands/syncdb.py26
1 files changed, 12 insertions, 14 deletions
diff --git a/django/core/management/commands/syncdb.py b/django/core/management/commands/syncdb.py
index e7e11a8c90..ab80d8aece 100644
--- a/django/core/management/commands/syncdb.py
+++ b/django/core/management/commands/syncdb.py
@@ -121,16 +121,15 @@ class Command(NoArgsCommand):
if custom_sql:
if verbosity >= 2:
self.stdout.write("Installing custom SQL for %s.%s model\n" % (app_name, model._meta.object_name))
- with transaction.commit_on_success_unless_managed(using=db):
- try:
+ try:
+ with transaction.commit_on_success_unless_managed(using=db):
for sql in custom_sql:
cursor.execute(sql)
- except Exception as e:
- self.stderr.write("Failed to install custom SQL for %s.%s model: %s\n" % \
- (app_name, model._meta.object_name, e))
- if show_traceback:
- traceback.print_exc()
- raise
+ except Exception as e:
+ self.stderr.write("Failed to install custom SQL for %s.%s model: %s\n" % \
+ (app_name, model._meta.object_name, e))
+ if show_traceback:
+ traceback.print_exc()
else:
if verbosity >= 3:
self.stdout.write("No custom SQL for %s.%s model\n" % (app_name, model._meta.object_name))
@@ -145,14 +144,13 @@ class Command(NoArgsCommand):
if index_sql:
if verbosity >= 2:
self.stdout.write("Installing index for %s.%s model\n" % (app_name, model._meta.object_name))
- with transaction.commit_on_success_unless_managed(using=db):
- try:
+ try:
+ with transaction.commit_on_success_unless_managed(using=db):
for sql in index_sql:
cursor.execute(sql)
- except Exception as e:
- self.stderr.write("Failed to install index for %s.%s model: %s\n" % \
- (app_name, model._meta.object_name, e))
- raise
+ except Exception as e:
+ self.stderr.write("Failed to install index for %s.%s model: %s\n" % \
+ (app_name, model._meta.object_name, e))
# Load initial_data fixtures (unless that has been disabled)
if load_initial_data: