summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2008-06-19 13:24:39 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2008-06-19 13:24:39 +0000
commit090aeee39979c279564c4673a1af2a6b15ce001e (patch)
tree876718c7b7385134dfd489f9f61a28600bdef8db
parenta7f6faaa818d91aa9baaf1db99974cb1209c8ee6 (diff)
Fixed #6719 -- Added a --traceback option to syncdb to provide a stack trace when custom SQL loading fails. Also added documentation for the --traceback option. Thanks to guettli for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7704 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/management/commands/syncdb.py10
-rw-r--r--docs/django-admin.txt11
2 files changed, 19 insertions, 2 deletions
diff --git a/django/core/management/commands/syncdb.py b/django/core/management/commands/syncdb.py
index d87644d049..91e78c96e8 100644
--- a/django/core/management/commands/syncdb.py
+++ b/django/core/management/commands/syncdb.py
@@ -25,6 +25,7 @@ class Command(NoArgsCommand):
verbosity = int(options.get('verbosity', 1))
interactive = options.get('interactive')
+ show_traceback = options.get('traceback', False)
self.style = no_style()
@@ -119,12 +120,17 @@ class Command(NoArgsCommand):
for sql in custom_sql:
cursor.execute(sql)
except Exception, e:
- sys.stderr.write("Failed to install custom SQL for %s.%s model: %s" % \
+ sys.stderr.write("Failed to install custom SQL for %s.%s model: %s\n" % \
(app_name, model._meta.object_name, e))
+ if show_traceback:
+ import traceback
+ traceback.print_exc()
transaction.rollback_unless_managed()
else:
transaction.commit_unless_managed()
-
+ else:
+ if verbosity >= 2:
+ print "No custom SQL for %s.%s model" % (app_name, model._meta.object_name)
# Install SQL indicies for all newly created models
for app in models.get_apps():
app_name = app.__name__.split('.')[-2]
diff --git a/docs/django-admin.txt b/docs/django-admin.txt
index 8797d2e988..309166fe94 100644
--- a/docs/django-admin.txt
+++ b/docs/django-admin.txt
@@ -756,6 +756,17 @@ variable.
Note that this option is unnecessary in ``manage.py``, because it uses
``settings.py`` from the current project by default.
+--traceback
+-----------
+
+Example usage::
+
+ django-admin.py syncdb --traceback
+
+By default, ``django-admin.py`` will show a simple error message whenever an
+error occurs. If you specify ``--traceback``, ``django-admin.py`` will
+output a full stack trace whenever an exception is raised.
+
Extra niceties
==============