Commit 090aeee3 authored by Russell Keith-Magee's avatar Russell Keith-Magee
Browse files

Fixed #6719 -- Added a --traceback option to syncdb to provide a stack trace...

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
parent a7f6faaa
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -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]
+11 −0
Original line number Diff line number Diff line
@@ -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
==============