Ticket #13826: final_post_sync.diff
File final_post_sync.diff, 3.1 KB (added by , 14 years ago) |
---|
-
django/db/models/signals.py
12 12 post_delete = Signal(providing_args=["instance"]) 13 13 14 14 post_syncdb = Signal(providing_args=["class", "app", "created_models", "verbosity", "interactive"]) 15 final_post_syncdb = Signal(providing_args=["class", "app", "created_models", "verbosity", "interactive"]) 15 16 16 17 m2m_changed = Signal(providing_args=["action", "instance", "reverse", "model", "pk_set"]) -
django/core/management/commands/syncdb.py
4 4 from django.conf import settings 5 5 from django.core.management.base import NoArgsCommand 6 6 from django.core.management.color import no_style 7 from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal 7 from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal,emit_final_post_sync_signal 8 8 from django.db import connections, router, transaction, models, DEFAULT_DB_ALIAS 9 9 from django.utils.datastructures import SortedDict 10 10 from django.utils.importlib import import_module … … 148 148 else: 149 149 transaction.commit_unless_managed(using=db) 150 150 151 # Send the post_syncdb signal, so individual apps can do whatever they need 152 # to do at this point. 153 emit_final_post_sync_signal(created_models, verbosity, interactive, db) 154 155 # The connection may have been closed by a syncdb handler. 156 cursor = connection.cursor() 157 151 158 from django.core.management import call_command 152 159 call_command('loaddata', 'initial_data', verbosity=verbosity, database=db) -
django/core/management/sql.py
175 175 176 176 177 177 def emit_post_sync_signal(created_models, verbosity, interactive, db): 178 return emit_signal_to_models(models.signals.post_syncdb,"post-sync",created_models,verbosity,interactive,db) 179 180 def emit_final_post_sync_signal(created_models,verbosity,interactive,db): 181 return emit_signal_to_models(models.signals.final_post_syncdb,"final-post-sync",created_models,verbosity,interactive,db) 182 183 def emit_signal_to_models(signal,signal_name,created_models,verbosity,interactive,db): 178 184 # Emit the post_sync signal for every application. 179 185 for app in models.get_apps(): 180 186 app_name = app.__name__.split('.')[-2] 181 187 if verbosity >= 2: 182 print "Running post-synchandlers for application", app_name183 models.signals.post_syncdb.send(sender=app, app=app,188 print "Running", signal_name,"handlers for application", app_name 189 signal.send(sender=app, app=app, 184 190 created_models=created_models, verbosity=verbosity, 185 191 interactive=interactive, db=db)