From 6519e364cf264d23e3cb966a2f2ad46567d3d1ea Mon Sep 17 00:00:00 2001 From: SimonGreenhill Date: Tue, 16 Aug 2016 13:52:40 +0200 Subject: [PATCH] fixing args handling in buildwatson --- src/watson/management/commands/buildwatson.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/watson/management/commands/buildwatson.py b/src/watson/management/commands/buildwatson.py index ad4b0e1..de257c1 100644 --- a/src/watson/management/commands/buildwatson.py +++ b/src/watson/management/commands/buildwatson.py @@ -79,10 +79,16 @@ class Command(BaseCommand): engine_slug = "default" engine_selected = False + # work-around for legacy optparser hack in BaseCommand. In Django=1.10 the + # args are collected in options['apps'], but in earlier versions they are + # kept in args. + if len(options['apps']): + args = options['apps'] + # get the search engine we'll be checking registered models for, may be "default" search_engine = get_engine(engine_slug) models = [] - for model_name in options.get('apps', []): + for model_name in args: try: model = apps.get_model(*model_name.split(".")) # app label, model name except TypeError: # were we given only model name without app_name?