Skip to content

Commit 8d830b2

Browse files
iXceauvipy
authored andcommitted
Fix management command handling for django >= 1.10 (#458)
1 parent 747ac59 commit 8d830b2

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

djcelery/management/base.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,29 @@ def _validate_thread_sharing(self):
5454

5555

5656
class CeleryCommand(BaseCommand):
57-
options = BaseCommand.option_list
57+
options = ()
58+
if hasattr(BaseCommand, 'option_list'):
59+
options = BaseCommand.option_list
60+
else:
61+
def add_arguments(self, parser):
62+
option_typemap = {
63+
"string": str,
64+
"int": int,
65+
"float": float
66+
}
67+
for opt in self.option_list:
68+
option = {k: v
69+
for k, v in opt.__dict__.items()
70+
if v is not None}
71+
flags = (option.get("_long_opts", []) +
72+
option.get("_short_opts", []))
73+
del option["_long_opts"]
74+
del option["_short_opts"]
75+
if "type" in option:
76+
opttype = option["type"]
77+
option["type"] = option_typemap.get(opttype, opttype)
78+
parser.add_argument(*flags, **option)
79+
5880
skip_opts = ['--app', '--loader', '--config', '--no-color']
5981
requires_system_checks = False
6082
keep_base_opts = False

0 commit comments

Comments
 (0)