Code

Ticket #12407: document-call-command.diff

File document-call-command.diff, 985 bytes (added by adamv, 3 years ago)
Line 
1diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt
2index eeb5fee..821b37f 100644
3--- a/docs/ref/django-admin.txt
4+++ b/docs/ref/django-admin.txt
5@@ -1338,3 +1338,27 @@ distribution. It enables tab-completion of ``django-admin.py`` and
6 
7 
8 See :doc:`/howto/custom-management-commands` for how to add customized actions.
9+
10+
11+==========================================
12+Running management commands from your code
13+==========================================
14+
15+.. function:: django.core.management.call_command(name, *args, **options)
16+
17+To call a management command from code use ``call_command``.
18+
19+``name``
20+  the name of the command to call.
21+
22+``*args``
23+  a list of arguments accepted by the command.
24+
25+``**options``
26+  named options accepted on the command-line.
27+
28+Examples::
29+
30+      from django.core import management
31+      management.call_command('flush', verbosity=0, interactive=False)
32+      management.call_command('loaddata', 'test_data', verbosity=0)