Skip to content

Commit 389c72c

Browse files
committed
[1.2.X] Fixed #14025 -- Modified flush to adhere to router sync instructions when emmiting post-sync signals. Thanks to linovia for the patch.
Backport of r13466 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@13467 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent 972a9c7 commit 389c72c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

django/core/management/commands/flush.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from optparse import make_option
22

33
from django.conf import settings
4-
from django.db import connections, transaction, models, DEFAULT_DB_ALIAS
4+
from django.db import connections, router, transaction, models, DEFAULT_DB_ALIAS
55
from django.core.management import call_command
66
from django.core.management.base import NoArgsCommand, CommandError
77
from django.core.management.color import no_style
@@ -66,7 +66,13 @@ def handle_noargs(self, **options):
6666
# Emit the post sync signal. This allows individual
6767
# applications to respond as if the database had been
6868
# sync'd from scratch.
69-
emit_post_sync_signal(models.get_models(), verbosity, interactive, db)
69+
all_models = [
70+
(app.__name__.split('.')[-2],
71+
[m for m in models.get_models(app, include_auto_created=True)
72+
if router.allow_syncdb(db, m)])
73+
for app in models.get_apps()
74+
]
75+
emit_post_sync_signal(all_models, verbosity, interactive, db)
7076

7177
# Reinstall the initial_data fixture.
7278
kwargs = options.copy()

0 commit comments

Comments
 (0)