Ticket #15113: flush.diff

File flush.diff, 1.6 KB (added by David Cramer, 14 years ago)

Diff against DISQUS codebase

  • django_root/django/core/management/commands/flush.py

    commit fe8c4cdc1a5020ae464d2a83c6a2de629c0a2e59
    Author: David Cramer <david@disqus.com>
    Date:   Tue Jan 18 15:40:18 2011 -0800
    
        Ensure the flush command only passes models which are on the selected database
    
    diff --git a/django_root/django/core/management/commands/flush.py b/django_root/django/core/management/commands/flush.py
    index 6836fe3..f15e202 100644
    a b  
    11from optparse import make_option
    22
    33from django.conf import settings
    4 from django.db import connections, transaction, models, DEFAULT_DB_ALIAS
     4from django.db import connections, router, transaction, models, DEFAULT_DB_ALIAS
    55from django.core.management import call_command
    66from django.core.management.base import NoArgsCommand, CommandError
    77from django.core.management.color import no_style
    The full error: %s""" % (connection.settings_dict['NAME'], e))  
    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           
     76            emit_post_sync_signal(all_models, verbosity, interactive, db)
    7077
    7178            # Reinstall the initial_data fixture.
    7279            kwargs = options.copy()
Back to Top