Ticket #15926: ticket15926-with-flush.patch

File ticket15926-with-flush.patch, 2.8 KB (added by Jonathan Paugh, 12 years ago)

Reincarnation of patch supporting the flush command as well

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

    diff --git a/django/core/management/commands/flush.py b/django/core/management/commands/flush.py
    index 87a99b8..25d6793 100644
    a b class Command(NoArgsCommand):  
    99            help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'),
    1010        make_option('--noinput', action='store_false', dest='interactive', default=True,
    1111            help='Tells Django to NOT prompt the user for input of any kind.'),
     12        make_option('--no-initial-data', action='store_false', dest='load_initial_data', default=True,
     13            help='Tells Django not to load any initial data after database synchronization.'),
    1214    )
    1315    help = "Executes ``sqlflush`` on the current database."
    1416
    Are you sure you want to do this?  
    6365            # sync'd from scratch.
    6466            emit_post_sync_signal(models.get_models(), verbosity, interactive)
    6567
    66             # Reinstall the initial_data fixture.
    67             from django.core.management import call_command
    68             call_command('loaddata', 'initial_data', **options)
     68            if options.get('load_initial_data', True):
     69              # Reinstall the initial_data fixture.
     70              from django.core.management import call_command
     71              call_command('loaddata', 'initial_data', **options)
    6972
    7073        else:
    7174            print "Flush cancelled."
  • django/core/management/commands/syncdb.py

    diff --git a/django/core/management/commands/syncdb.py b/django/core/management/commands/syncdb.py
    index 8017ed8..dbbbf84 100644
    a b class Command(NoArgsCommand):  
    1515            help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'),
    1616        make_option('--noinput', action='store_false', dest='interactive', default=True,
    1717            help='Tells Django to NOT prompt the user for input of any kind.'),
     18        make_option('--no-initial-data', action='store_false', dest='load_initial_data', default=True,
     19            help='Tells Django not to load any initial data after database synchronization.'),
    1820    )
    1921    help = "Create the database tables for all apps in INSTALLED_APPS whose tables haven't already been created."
    2022
    class Command(NoArgsCommand):  
    134136                            transaction.rollback_unless_managed()
    135137                        else:
    136138                            transaction.commit_unless_managed()
    137 
    138         # Install the 'initial_data' fixture, using format discovery
    139         from django.core.management import call_command
    140         call_command('loaddata', 'initial_data', verbosity=verbosity)
     139        if options.get('load_initial_data', true):
     140          # Install the 'initial_data' fixture, using format discovery
     141          from django.core.management import call_command
     142          call_command('loaddata', 'initial_data', verbosity=verbosity)
Back to Top