summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2012-02-09 18:56:41 +0000
committerJannis Leidel <jannis@leidel.info>2012-02-09 18:56:41 +0000
commit538257b4ae5cd8a5e3b9fc79c167294560101e18 (patch)
tree0139132b96e801acad4b1429be1bfe7f9a545734
parentb46d90c63ad866d5d7d6b09d8986339e0842550d (diff)
Fixed #10080 -- Slightly extended the fix made in r10401 by also taking command line options into account that don't have have a default set. Thanks, Claude Paroz.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17467 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/management/__init__.py9
-rw-r--r--tests/modeltests/user_commands/management/commands/dance.py4
2 files changed, 9 insertions, 4 deletions
diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py
index 6edfc1264c..8e8330484d 100644
--- a/django/core/management/__init__.py
+++ b/django/core/management/__init__.py
@@ -139,9 +139,12 @@ def call_command(name, *args, **options):
# when the script runs from the command line, but since call_command can
# be called programatically, we need to simulate the loading and handling
# of defaults (see #10080 for details).
- defaults = dict([(o.dest, o.default)
- for o in klass.option_list
- if o.default is not NO_DEFAULT])
+ defaults = {}
+ for opt in klass.option_list:
+ if opt.default is NO_DEFAULT:
+ defaults[opt.dest] = None
+ else:
+ defaults[opt.dest] = opt.default
defaults.update(options)
return klass.execute(*args, **defaults)
diff --git a/tests/modeltests/user_commands/management/commands/dance.py b/tests/modeltests/user_commands/management/commands/dance.py
index 34eb277567..4ad5579e1e 100644
--- a/tests/modeltests/user_commands/management/commands/dance.py
+++ b/tests/modeltests/user_commands/management/commands/dance.py
@@ -9,8 +9,10 @@ class Command(BaseCommand):
requires_model_validation = True
option_list =[
- make_option("-s", "--style", default="Rock'n'Roll")
+ make_option("-s", "--style", default="Rock'n'Roll"),
+ make_option("-x", "--example")
]
def handle(self, *args, **options):
+ example = options["example"]
self.stdout.write("I don't feel like dancing %s." % options["style"])