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 /docs/ref | |
| 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 'docs/ref')
| -rw-r--r-- | docs/ref/django-admin.txt | 19 |
1 files changed, 18 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']) |
