diff --git a/docs/howto/custom-management-commands.txt b/docs/howto/custom-management-commands.txt index e49e2b632a..74b67b2ac2 100644 --- a/docs/howto/custom-management-commands.txt +++ b/docs/howto/custom-management-commands.txt @@ -243,6 +243,11 @@ the :meth:`~BaseCommand.handle` method must be implemented. :class:`CommandError`, intercept it and print it sensibly to 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 ` instead. + .. method:: BaseCommand.handle(*args, **options) The actual logic of the command. Subclasses must implement this method. diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt index 40b5ee168f..bd99958fae 100644 --- a/docs/ref/django-admin.txt +++ b/docs/ref/django-admin.txt @@ -1490,6 +1490,8 @@ See :doc:`/howto/custom-management-commands` for how to add customized actions. Running management commands from your code ========================================== +.. _call-command: + .. function:: django.core.management.call_command(name, *args, **options) To call a management command from code use ``call_command``.