summaryrefslogtreecommitdiff
path: root/django/core
diff options
context:
space:
mode:
authorHonza Kral <honza.kral@gmail.com>2012-06-05 16:46:15 +0200
committerHonza Kral <honza.kral@gmail.com>2012-06-05 16:46:15 +0200
commitfedac99c859c626544d38fc0ea07207ef3fd101a (patch)
tree3ee63f15e355bdc31cfc25dded3cfac4189b5552 /django/core
parent4db34e7b4fabe4f70bce9429ee9814eb6168dc72 (diff)
Fixed #15926 -- Added option --no-initial-data to syncdb and flush.
Thanks msiedlarek, jpaugh64 and vlinhart!
Diffstat (limited to 'django/core')
-rw-r--r--django/core/management/commands/flush.py7
-rw-r--r--django/core/management/commands/syncdb.py5
2 files changed, 8 insertions, 4 deletions
diff --git a/django/core/management/commands/flush.py b/django/core/management/commands/flush.py
index ce3c6e856b..7eb71fd1bb 100644
--- a/django/core/management/commands/flush.py
+++ b/django/core/management/commands/flush.py
@@ -16,6 +16,8 @@ class Command(NoArgsCommand):
make_option('--database', action='store', dest='database',
default=DEFAULT_DB_ALIAS, help='Nominates a database to flush. '
'Defaults to the "default" database.'),
+ make_option('--no-initial-data', action='store_false', dest='load_initial_data', default=True,
+ help='Tells Django not to load any initial data after database synchronization.'),
)
help = ('Returns the database to the state it was in immediately after '
'syncdb was executed. This means that all data will be removed '
@@ -79,7 +81,10 @@ The full error: %s""" % (connection.settings_dict['NAME'], e))
# Reinstall the initial_data fixture.
kwargs = options.copy()
kwargs['database'] = db
- call_command('loaddata', 'initial_data', **kwargs)
+ if options.get('load_initial_data', True):
+ # Reinstall the initial_data fixture.
+ from django.core.management import call_command
+ call_command('loaddata', 'initial_data', **options)
else:
self.stdout.write("Flush cancelled.\n")
diff --git a/django/core/management/commands/syncdb.py b/django/core/management/commands/syncdb.py
index 88caea152c..f751a3768b 100644
--- a/django/core/management/commands/syncdb.py
+++ b/django/core/management/commands/syncdb.py
@@ -14,6 +14,8 @@ class Command(NoArgsCommand):
option_list = NoArgsCommand.option_list + (
make_option('--noinput', action='store_false', dest='interactive', default=True,
help='Tells Django to NOT prompt the user for input of any kind.'),
+ make_option('--no-initial-data', action='store_false', dest='load_initial_data', default=True,
+ help='Tells Django not to load any initial data after database synchronization.'),
make_option('--database', action='store', dest='database',
default=DEFAULT_DB_ALIAS, help='Nominates a database to synchronize. '
'Defaults to the "default" database.'),
@@ -25,9 +27,6 @@ class Command(NoArgsCommand):
verbosity = int(options.get('verbosity'))
interactive = options.get('interactive')
show_traceback = options.get('traceback')
-
- # Stealth option -- 'load_initial_data' is used by the testing setup
- # process to disable initial fixture loading.
load_initial_data = options.get('load_initial_data', True)
self.style = no_style()