Skip to content

Commit a2e9d65

Browse files
committed
Add option_list for older Djangos
1 parent 751c7f4 commit a2e9d65

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

simple_history/management/commands/populate_history.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from optparse import make_option
2+
13
from django.core.management.base import BaseCommand, CommandError
24

35
try:
@@ -25,6 +27,11 @@ class Command(BaseCommand):
2527
EXISTING_HISTORY_FOUND = "Existing history found, skipping model"
2628
INVALID_MODEL_ARG = "An invalid model was specified"
2729

30+
if hasattr(BaseCommand, 'option_list'): # Django < 1.8
31+
option_list = BaseCommand.option_list + (
32+
make_option('--auto', action='store_true', dest='auto', default=False),
33+
)
34+
2835
def add_arguments(self, parser):
2936
super(Command, self).add_arguments(parser)
3037
parser.add_argument('models', nargs='*', type=str)
@@ -39,7 +46,7 @@ def add_arguments(self, parser):
3946

4047
def handle(self, *args, **options):
4148
to_process = set()
42-
model_strings = options['models'] or args
49+
model_strings = options.get('models', []) or args
4350

4451
if model_strings:
4552
for model_pair in self._handle_model_list(*model_strings):

0 commit comments

Comments
 (0)