call_command doesn't take into account command's default options
|Reported by:||alexkoshelev||Owned by:||alexkoshelev|
|Cc:||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
When I want to use manage.py command from python I must specify all options on which this command is depend.
Almost everyone custom command's author write execute method something like this:
class Command(BaseCommand): option_list = [make_option("--some_option", default="foobar")] def execute(self, *args, **options): #... some_option = options["some_option"] #...
And when I call it using call_command without some_option is specified I get the KeyError. But it works fine in command line because optparse provides default values.
>>> call_command("some_command") Traceback (most recent call last): ... KeyError: 'some_option'
Patch solves this inconsistence.
Change History (12)
Changed 7 years ago by alexkoshelev
comment:2 Changed 7 years ago by jacob
- milestone set to 1.1
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
comment:4 Changed 6 years ago by bjourne
- Resolution fixed deleted
- Status changed from closed to reopened
Changed 5 years ago by claudep
comment:9 Changed 4 years ago by jezdez
- Resolution set to fixed
- Status changed from reopened to closed