summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2014-10-27 07:03:05 -0400
committerTim Graham <timograham@gmail.com>2014-10-27 07:13:05 -0400
commit5cc8180a651b11f00a0a05296f8db15db1e48cdc (patch)
tree4abeb9d6ff983a38264e7bea76bf83139f9b5ef9 /django
parente317d7fc7269061d12f71bf87d2f1b9e8da1ec8b (diff)
[1.7.x] Fixed #23699 -- Prevented flush from loading initial data for apps with migrations.
Backport of dd1ea70779 from master.
Diffstat (limited to 'django')
-rw-r--r--django/core/management/commands/flush.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/django/core/management/commands/flush.py b/django/core/management/commands/flush.py
index 637d6d525b..bad80c2e0b 100644
--- a/django/core/management/commands/flush.py
+++ b/django/core/management/commands/flush.py
@@ -84,9 +84,13 @@ Are you sure you want to do this?
# Reinstall the initial_data fixture.
if options.get('load_initial_data'):
- # Reinstall the initial_data fixture.
- call_command('loaddata', 'initial_data', **options)
-
+ # Reinstall the initial_data fixture for apps without migrations.
+ from django.db.migrations.executor import MigrationExecutor
+ executor = MigrationExecutor(connection)
+ app_options = options.copy()
+ for app_label in executor.loader.unmigrated_apps:
+ app_options['app_label'] = app_label
+ call_command('loaddata', 'initial_data', **app_options)
else:
self.stdout.write("Flush cancelled.\n")