diff options
| author | Claude Paroz <claude@2xlibre.net> | 2014-08-09 21:03:19 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2014-08-12 21:53:29 +0200 |
| commit | 2cc8ffe258008096a70791115b2daa12f0ef0192 (patch) | |
| tree | 8d30f9ed8fc1c1931d35ecc5410f164a1171f3eb /django | |
| parent | 8f9862cd4d0e9706babf947079739fd476455df7 (diff) | |
Fixed #22985 -- Made call_command accept option name parameter
Thanks giulettamasina for the report and Tim Graham for the review.
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/management/__init__.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py index 75cd48461c..d74befa844 100644 --- a/django/core/management/__init__.py +++ b/django/core/management/__init__.py @@ -102,8 +102,12 @@ def call_command(name, *args, **options): # Simulate argument parsing to get the option defaults (see #10080 for details). parser = command.create_parser('', name) if command.use_argparse: + # Use the `dest` option name from the parser option + opt_mapping = dict((sorted(s_opt.option_strings)[0].lstrip('-').replace('-', '_'), s_opt.dest) + for s_opt in parser._actions if s_opt.option_strings) + arg_options = dict((opt_mapping.get(key, key), value) for key, value in options.items()) defaults = parser.parse_args(args=args) - defaults = dict(defaults._get_kwargs(), **options) + defaults = dict(defaults._get_kwargs(), **arg_options) else: # Legacy optparse method defaults, _ = parser.parse_args(args=[]) |
