Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #6719 -- Added a --traceback option to syncdb to provide a stac…

…k 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
  • Loading branch information...
commit 090aeee39979c279564c4673a1af2a6b15ce001e 1 parent a7f6faa
Russell Keith-Magee freakboy3742 authored
Showing with 19 additions and 2 deletions.
  1. +8 −2 django/core/management/commands/syncdb.py
  2. +11 −0 docs/django-admin.txt
10 django/core/management/commands/syncdb.py
View
@@ -25,6 +25,7 @@ def handle_noargs(self, **options):
verbosity = int(options.get('verbosity', 1))
interactive = options.get('interactive')
+ show_traceback = options.get('traceback', False)
self.style = no_style()
@@ -119,12 +120,17 @@ def handle_noargs(self, **options):
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]
11 docs/django-admin.txt
View
@@ -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
==============
Please sign in to comment.
Something went wrong with that request. Please try again.