38
38
.. code-block:: bash
40
django-admin.py <subcommand> [options]
41
manage.py <subcommand> [options]
40
django-admin.py <command> [options]
41
manage.py <command> [options]
43
``subcommand`` should be one of the subcommands listed in this document.
43
``command`` should be one of the commands listed in this document.
44
44
``options``, which is optional, should be zero or more of the options available
45
for the given subcommand.
45
for the given command.
47
47
Getting runtime help
48
48
--------------------
50
50
.. django-admin-option:: --help
52
Run ``django-admin.py help`` to display a list of all available subcommands.
53
Run ``django-admin.py help <subcommand>`` to display a description of the
54
given subcommand and a list of its available options.
52
Run ``django-admin.py help`` to display a list of all available commands.
53
Run ``django-admin.py help <command>`` to display a description of the
54
given command and a list of its available options.
59
Many subcommands take a list of "app names." An "app name" is the basename of
59
Many commands take a list of "app names." An "app name" is the basename of
60
60
the package containing your models. For example, if your ``INSTALLED_APPS``
61
61
contains the string ``'mysite.blog'``, the app name is ``blog``.
124
119
The :djadminopt:`--database` option can be used to specify the database
125
120
onto which the cachetable will be installed.
130
.. django-admin:: createsuperuser
132
.. versionadded:: 1.0
134
Creates a superuser account (a user who has all permissions). This is
135
useful if you need to create an initial superuser account but did not
136
do so during ``syncdb``, or if you need to programmatically generate
137
superuser accounts for your site(s).
139
When run interactively, this command will prompt for a password for
140
the new superuser account. When run non-interactively, no password
141
will be set, and the superuser account will not be able to log in until
142
a password has been manually set for it.
144
.. django-admin-option:: --username
145
.. django-admin-option:: --email
147
The username and e-mail address for the new account can be supplied by
148
using the ``--username`` and ``--email`` arguments on the command
149
line. If either of those is not supplied, ``createsuperuser`` will prompt for
150
it when running interactively.
152
This command is only available if Django's :doc:`authentication system
153
</topics/auth>` (``django.contrib.auth``) is installed.
529
489
.. _flup: http://www.saddi.com/software/flup/
491
The options accepted by this command are passed to the FastCGI library and
492
don't use the ``'--'`` prefix as is usual for other Django management commands.
494
.. django-admin-option:: protocol
496
``protocol=PROTOCOL``
498
Protocol to use. *PROTOCOL* can be ``fcgi``, ``scgi``, ``ajp``, etc.
499
(default is ``fcgi``)
501
.. django-admin-option:: host
505
Hostname to listen on.
507
.. django-admin-option:: port
513
.. django-admin-option:: socket
517
UNIX socket to listen on.
519
.. django-admin-option:: method
523
Possible values: ``prefork`` or ``threaded`` (default ``prefork``)
525
.. django-admin-option:: maxrequests
527
``maxrequests=NUMBER``
529
Number of requests a child handles before it is killed and a new child is
530
forked (0 means no limit).
532
.. django-admin-option:: maxspare
536
Max number of spare processes / threads.
538
.. django-admin-option:: minspare
542
Min number of spare processes / threads.
544
.. django-admin-option:: maxchildren
546
``maxchildren=NUMBER``
548
Hard limit number of processes / threads.
550
.. django-admin-option:: daemonize
554
Whether to detach from terminal.
556
.. django-admin-option:: pidfile
560
Write the spawned process-id to file *FILE*.
562
.. django-admin-option:: workdir
564
``workdir=DIRECTORY``
566
Change to directory *DIRECTORY* when daemonizing.
568
.. django-admin-option:: debug
572
Set to true to enable flup tracebacks.
574
.. django-admin-option:: outlog
578
Write stdout to the *FILE* file.
580
.. django-admin-option:: errlog
584
Write stderr to the *FILE* file.
586
.. django-admin-option:: umask
590
Umask to use when daemonizing. The value is interpeted as an octal number
591
(default value is ``022``).
595
django-admin.py runfcgi socket=/tmp/fcgi.sock method=prefork daemonize=true \
596
pidfile=/var/run/django-fcgi.pid
598
Run a FastCGI server as a daemon and write the spawned PID in a file.
531
600
runserver [port or ipaddr:port]
532
601
-------------------------------
895
962
Validates all installed models (according to the ``INSTALLED_APPS`` setting)
896
963
and prints validation errors to standard output.
965
Commands provided by applications
966
=================================
968
Some commands are only available when the ``django.contrib`` application that
969
:doc:`implements </howto/custom-management-commands>` them has been
970
:setting:`enabled <INSTALLED_APPS>`. This section describes them grouped by
973
``django.contrib.auth``
974
-----------------------
979
.. django-admin:: changepassword
981
.. versionadded:: 1.2
983
This command is only available if Django's :doc:`authentication system
984
</topics/auth>` (``django.contrib.auth``) is installed.
986
Allows changing a user's password. It prompts you to enter twice the password of
987
the user given as parameter. If they both match, the new password will be
988
changed immediately. If you do not supply a user, the command will attempt to
989
change the password whose username matches the current user.
993
django-admin.py changepassword ringo
998
.. django-admin:: createsuperuser
1000
This command is only available if Django's :doc:`authentication system
1001
</topics/auth>` (``django.contrib.auth``) is installed.
1003
Creates a superuser account (a user who has all permissions). This is
1004
useful if you need to create an initial superuser account but did not
1005
do so during ``syncdb``, or if you need to programmatically generate
1006
superuser accounts for your site(s).
1008
When run interactively, this command will prompt for a password for
1009
the new superuser account. When run non-interactively, no password
1010
will be set, and the superuser account will not be able to log in until
1011
a password has been manually set for it.
1013
.. django-admin-option:: --username
1014
.. django-admin-option:: --email
1016
The username and e-mail address for the new account can be supplied by
1017
using the ``--username`` and ``--email`` arguments on the command
1018
line. If either of those is not supplied, ``createsuperuser`` will prompt for
1019
it when running interactively.
1021
``django.contrib.gis``
1022
----------------------
1027
This command is only available if :doc:`GeoDjango </ref/contrib/gis/index>`
1028
(``django.contrib.gis``) is installed.
1030
Please refer to its :djadmin:`description <ogrinspect>` in the GeoDjango
1033
``django.contrib.sitemaps``
1034
---------------------------
1039
This command is only available if the :doc:`Sitemaps framework
1040
</ref/contrib/sitemaps>` (``django.contrib.sitemaps``) is installed.
1042
Please refer to its :djadmin:`description <ping_google>` in the Sitemaps
901
Although some subcommands may allow their own custom options, every subcommand
1048
Although some commands may allow their own custom options, every command
902
1049
allows for the following options:
904
1051
.. django-admin-option:: --pythonpath
1108
1255
See :doc:`/howto/custom-management-commands` for how to add customized actions.
1258
==========================================
1259
Running management commands from your code
1260
==========================================
1262
.. function:: django.core.management.call_command(name, *args, **options)
1264
To call a management command from code use ``call_command``.
1267
the name of the command to call.
1270
a list of arguments accepted by the command.
1273
named options accepted on the command-line.
1277
from django.core import management
1278
management.call_command('flush', verbosity=0, interactive=False)
1279
management.call_command('loaddata', 'test_data', verbosity=0)