1
0
mirror of https://github.com/django/django.git synced 2024-12-23 09:36:06 +00:00

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
This commit is contained in:
Russell Keith-Magee 2008-06-19 13:24:39 +00:00
parent a7f6faaa81
commit 090aeee399
2 changed files with 19 additions and 2 deletions

View File

@ -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]

View File

@ -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
==============