Kaydet (Commit) 3ed0b6ed authored tarafından Carl Meyer's avatar Carl Meyer

Fixed #17799 - Documented that the execute() method of a management command is…

Fixed #17799 - Documented that the execute() method of a management command is not suitable for calling the command from code; call_command should be used instead. Thanks kacah222 for the report and claudep for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17629 bcc190cf-cafb-0310-a4f2-bffc1f526a37
üst fcaf8eae
...@@ -243,6 +243,11 @@ the :meth:`~BaseCommand.handle` method must be implemented. ...@@ -243,6 +243,11 @@ the :meth:`~BaseCommand.handle` method must be implemented.
:class:`CommandError`, intercept it and print it sensibly to :class:`CommandError`, intercept it and print it sensibly to
stderr. stderr.
.. admonition:: Calling a management command in your code
``execute()`` should not be called directly from your code to execute a
command. Use :ref:`call_command <call-command>` instead.
.. method:: BaseCommand.handle(*args, **options) .. method:: BaseCommand.handle(*args, **options)
The actual logic of the command. Subclasses must implement this method. The actual logic of the command. Subclasses must implement this method.
......
...@@ -1490,6 +1490,8 @@ See :doc:`/howto/custom-management-commands` for how to add customized actions. ...@@ -1490,6 +1490,8 @@ See :doc:`/howto/custom-management-commands` for how to add customized actions.
Running management commands from your code Running management commands from your code
========================================== ==========================================
.. _call-command:
.. function:: django.core.management.call_command(name, *args, **options) .. function:: django.core.management.call_command(name, *args, **options)
To call a management command from code use ``call_command``. To call a management command from code use ``call_command``.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment