for app in models.get_apps():
# Install each application (models already installed will be skipped)
- created = _install(app, commit=False, initial_data=False)
+ created, pending = _install(app, commit=False, initial_data=False,
+ pending_allowed=True, pending=pending)
print "Created table %s" % model._meta.db_table
+ raise Exception("All apps were installed, but there were still "
+ "pending references to: " + ",".join(pending.keys()) +
+ ". Transaction rolled back.")
# Send the post_syncdb signal, so individual apps can do whatever they need
# doesn't complain about unprintable output.
-def _install(app, commit=True, initial_data=True):
+def _install(app, commit=True, initial_data=True, pending_allowed=False,
from django.db import connection, models, transaction
for model in models.get_models(app, creation_order=True):
manager = model._default_manager
tables = manager.get_table_list()
for statement in manager.get_pending(rel_class, f):
raise Exception("%s is not installed, but it has pending "
+ return created_models
install.help_doc = "Executes ``sqlall`` for the given app(s) in the current database."