diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2016-03-02 17:12:56 -0800 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-03-05 13:05:10 -0500 |
| commit | 4115288b4f7bbd694946a1ddef0f0ba85c03f9a1 (patch) | |
| tree | 829552eea236ba5cf7cccdb873e014bfff6a6036 /docs/ref | |
| parent | 8d3fcfa39e8aab5618d9b7f6a592006e9af8cefc (diff) | |
Fixed #26315 -- Allowed call_command() to accept a Command object as the first argument.
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/django-admin.txt | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt index 6a7752f40c..7ba33f5d17 100644 --- a/docs/ref/django-admin.txt +++ b/docs/ref/django-admin.txt @@ -1760,7 +1760,8 @@ Running management commands from your code To call a management command from code use ``call_command``. ``name`` - the name of the command to call. + the name of the command to call or a command object. Passing the name is + preferred unless the object is required for testing. ``*args`` a list of arguments accepted by the command. @@ -1771,8 +1772,11 @@ To call a management command from code use ``call_command``. Examples:: from django.core import management + from django.core.management.commands import loaddata + management.call_command('flush', verbosity=0, interactive=False) management.call_command('loaddata', 'test_data', verbosity=0) + management.call_command(loaddata.Command(), 'test_data', verbosity=0) Note that command options that take no arguments are passed as keywords with ``True`` or ``False``, as you can see with the ``interactive`` option above. @@ -1799,7 +1803,8 @@ value of the ``handle()`` method of the command. .. versionchanged:: 1.10 ``call_command()`` now returns the value received from the - ``command.handle()`` method. + ``command.handle()`` method. It now also accepts a command object as the + first argument. Output redirection ================== |
