Ticket #11398: pre_syncdb.diff
File pre_syncdb.diff, 2.8 KB (added by , 15 years ago) |
---|
-
django/core/management/commands/syncdb.py
a b class Command(NoArgsCommand): 19 19 def handle_noargs(self, **options): 20 20 from django.db import connection, transaction, models 21 21 from django.conf import settings 22 from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal 22 from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal, emit_pre_sync_signal 23 23 24 24 verbosity = int(options.get('verbosity', 1)) 25 25 interactive = options.get('interactive') … … class Command(NoArgsCommand): 54 54 created_models = set() 55 55 pending_references = {} 56 56 57 models_to_be_created = [] 58 for app in models.get_apps(): 59 app_name = app.__name__.split('.')[-2] 60 model_list = models.get_models(app) 61 for model in model_list: 62 if connection.introspection.table_name_converter(model._meta.db_table) in tables: 63 continue 64 models_to_be_created.append(model) 65 66 # Send the post_syncdb signal, so individual apps can do whatever they need 67 # to do at this point. 68 emit_pre_sync_signal(models_to_be_created, verbosity, interactive) 69 70 57 71 # Create the tables for each model 58 72 for app in models.get_apps(): 59 73 app_name = app.__name__.split('.')[-2] -
django/core/management/sql.py
diff --git a/django/core/management/sql.py b/django/core/management/sql.py
a b def emit_post_sync_signal(created_models, verbosity, interactive): 203 203 models.signals.post_syncdb.send(sender=app, app=app, 204 204 created_models=created_models, verbosity=verbosity, 205 205 interactive=interactive) 206 207 def emit_pre_sync_signal(models_to_be_created, verbosity, interactive): 208 from django.db import models 209 from django.dispatch import dispatcher 210 # Emit the pre_sync signal for every application. 211 for app in models.get_apps(): 212 app_name = app.__name__.split('.')[-2] 213 if verbosity >= 2: 214 print "Running pre-sync handlers for application", app_name 215 models.signals.pre_syncdb.send(sender=app, app=app, 216 models_to_be_created=models_to_be_created, verbosity=verbosity, 217 interactive=interactive) -
django/db/models/signals.py
diff --git a/django/db/models/signals.py b/django/db/models/signals.py
a b pre_delete = Signal(providing_args=["instance"]) 12 12 post_delete = Signal(providing_args=["instance"]) 13 13 14 14 post_syncdb = Signal(providing_args=["class", "app", "created_models", "verbosity", "interactive"]) 15 pre_syncdb = Signal(providing_args=["class", "app", "models_to_be_created", "verbosity", "interactive"])