summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2014-08-09 21:03:19 +0200
committerClaude Paroz <claude@2xlibre.net>2014-08-12 21:53:29 +0200
commit2cc8ffe258008096a70791115b2daa12f0ef0192 (patch)
tree8d30f9ed8fc1c1931d35ecc5410f164a1171f3eb /docs
parent8f9862cd4d0e9706babf947079739fd476455df7 (diff)
Fixed #22985 -- Made call_command accept option name parameter
Thanks giulettamasina for the report and Tim Graham for the review.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/django-admin.txt19
-rw-r--r--docs/releases/1.8.txt7
2 files changed, 25 insertions, 1 deletions
diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt
index d271eafc00..85d0ab06fe 100644
--- a/docs/ref/django-admin.txt
+++ b/docs/ref/django-admin.txt
@@ -1824,10 +1824,27 @@ Examples::
management.call_command('loaddata', 'test_data', verbosity=0)
Note that command options that take no arguments are passed as keywords
-with ``True`` or ``False``::
+with ``True`` or ``False``, as you can see with the ``interactive`` option above.
+Named arguments can be passed by using either one of the following syntaxes::
+
+ # Similar to the command line
+ management.call_command('dumpdata', '--natural')
+
+ # Named argument similar to the command line minus the initial dashes and
+ # with internal dashes replaced by underscores
+ management.call_command('dumpdata', natural=True)
+
+ # `use_natural_keys` is the option destination variable
management.call_command('dumpdata', use_natural_keys=True)
+.. versionchanged:: 1.8
+
+ The first syntax is now supported thanks to management commands using the
+ :py:mod:`argparse` module. For the second syntax, Django previously passed
+ the option name as-is to the command, now it is always using the ``dest``
+ variable name (which may or may not be the same as the option name).
+
Command options which take multiple options are passed a list::
management.call_command('dumpdata', exclude=['contenttypes', 'auth'])
diff --git a/docs/releases/1.8.txt b/docs/releases/1.8.txt
index 318b6ce49f..86d39c4f88 100644
--- a/docs/releases/1.8.txt
+++ b/docs/releases/1.8.txt
@@ -196,6 +196,13 @@ Management Commands
* :djadmin:`inspectdb` now outputs ``Meta.unique_together``.
+* When calling management commands from code through :ref:`call_command
+ <call-command>` and passing options, the option name can match the command
+ line option name (without the initial dashes) or the final option destination
+ variable name, but in either case, the resulting option received by the
+ command is now always the ``dest`` name specified in the command option
+ definition (as long as the command uses the new :py:mod:`argparse` module).
+
Models
^^^^^^