@@ -95,39 +95,43 @@ def flushdb():
95
95
96
96
def _handle_south ():
97
97
from django .conf import settings
98
- if 'south' in settings .INSTALLED_APPS :
99
- # Handle south.
100
- from django .core import management
101
-
102
- try :
103
- # if `south` >= 0.7.1 we can use the test helper
104
- from south .management .commands import patch_for_test_db_setup
105
- except ImportError :
106
- # if `south` < 0.7.1 make sure it's migrations are disabled
107
- management .get_commands ()
108
- management ._commands ['syncdb' ] = 'django.core'
109
- else :
110
- # Monkey-patch south.hacks.django_1_0.SkipFlushCommand to load
111
- # initial data.
112
- # Ref: http://south.aeracode.org/ticket/1395#comment:3
113
- import south .hacks .django_1_0
114
- from django .core .management .commands .flush import (
115
- Command as FlushCommand )
116
-
117
- class SkipFlushCommand (FlushCommand ):
118
- def handle_noargs (self , ** options ):
98
+
99
+ # NOTE: Django 1.7 does not have `management._commands` anymore, which
100
+ # is used by South's `patch_for_test_db_setup` and the code below.
101
+ if 'south' not in settings .INSTALLED_APPS or get_django_version () > (1 , 7 ):
102
+ return
103
+
104
+ from django .core import management
105
+
106
+ try :
107
+ # if `south` >= 0.7.1 we can use the test helper
108
+ from south .management .commands import patch_for_test_db_setup
109
+ except ImportError :
110
+ # if `south` < 0.7.1 make sure it's migrations are disabled
111
+ management .get_commands ()
112
+ management ._commands ['syncdb' ] = 'django.core'
113
+ else :
114
+ # Monkey-patch south.hacks.django_1_0.SkipFlushCommand to load
115
+ # initial data.
116
+ # Ref: http://south.aeracode.org/ticket/1395#comment:3
117
+ import south .hacks .django_1_0
118
+ from django .core .management .commands .flush import (
119
+ Command as FlushCommand )
120
+
121
+ class SkipFlushCommand (FlushCommand ):
122
+ def handle_noargs (self , ** options ):
123
+ # Reinstall the initial_data fixture.
124
+ from django .core .management import call_command
125
+ # `load_initial_data` got introduces with Django 1.5.
126
+ load_initial_data = options .get ('load_initial_data' , None )
127
+ if load_initial_data or load_initial_data is None :
119
128
# Reinstall the initial_data fixture.
120
- from django .core .management import call_command
121
- # `load_initial_data` got introduces with Django 1.5.
122
- load_initial_data = options .get ('load_initial_data' , None )
123
- if load_initial_data or load_initial_data is None :
124
- # Reinstall the initial_data fixture.
125
- call_command ('loaddata' , 'initial_data' , ** options )
126
- # no-op to avoid calling flush
127
- return
128
- south .hacks .django_1_0 .SkipFlushCommand = SkipFlushCommand
129
-
130
- patch_for_test_db_setup ()
129
+ call_command ('loaddata' , 'initial_data' , ** options )
130
+ # no-op to avoid calling flush
131
+ return
132
+ south .hacks .django_1_0 .SkipFlushCommand = SkipFlushCommand
133
+
134
+ patch_for_test_db_setup ()
131
135
132
136
133
137
def _disable_native_migrations ():
0 commit comments