From 24016a940b8e36e9116181c429c545f25fc2d922 Mon Sep 17 00:00:00 2001 From: Guillaume Seguin Date: Tue, 9 Aug 2016 17:50:50 +0000 Subject: [PATCH] Fix management command handling for django >= 1.10 --- djcelery/management/base.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/djcelery/management/base.py b/djcelery/management/base.py index 8c645056..5e86a0fa 100644 --- a/djcelery/management/base.py +++ b/djcelery/management/base.py @@ -54,7 +54,29 @@ def _validate_thread_sharing(self): class CeleryCommand(BaseCommand): - options = BaseCommand.option_list + options = () + if hasattr(BaseCommand, 'option_list'): + options = BaseCommand.option_list + else: + def add_arguments(self, parser): + option_typemap = { + "string": str, + "int": int, + "float": float + } + for opt in self.option_list: + option = {k: v + for k, v in opt.__dict__.items() + if v is not None} + flags = (option.get("_long_opts", []) + + option.get("_short_opts", [])) + del option["_long_opts"] + del option["_short_opts"] + if "type" in option: + opttype = option["type"] + option["type"] = option_typemap.get(opttype, opttype) + parser.add_argument(*flags, **option) + skip_opts = ['--app', '--loader', '--config', '--no-color'] requires_system_checks = False keep_base_opts = False