2007-09-22 00:19:20 +08:00
|
|
|
"""
|
2007-12-02 05:18:45 +08:00
|
|
|
38. User-registered management commands
|
2007-09-22 00:19:20 +08:00
|
|
|
|
2008-08-12 22:15:38 +08:00
|
|
|
The ``manage.py`` utility provides a number of useful commands for managing a
|
2007-09-22 00:19:20 +08:00
|
|
|
Django project. If you want to add a utility command of your own, you can.
|
|
|
|
|
2008-08-12 22:15:38 +08:00
|
|
|
The user-defined command ``dance`` is defined in the management/commands
|
|
|
|
subdirectory of this test application. It is a simple command that responds
|
2007-09-22 00:19:20 +08:00
|
|
|
with a printed message when invoked.
|
|
|
|
|
2008-08-12 22:15:38 +08:00
|
|
|
For more details on how to define your own ``manage.py`` commands, look at the
|
|
|
|
``django.core.management.commands`` directory. This directory contains the
|
|
|
|
definitions for the base Django ``manage.py`` commands.
|
2007-09-22 00:19:20 +08:00
|
|
|
"""
|
|
|
|
|
|
|
|
__test__ = {'API_TESTS': """
|
|
|
|
>>> from django.core import management
|
|
|
|
|
|
|
|
# Invoke a simple user-defined command
|
2009-04-06 01:27:26 +08:00
|
|
|
>>> management.call_command('dance', style="Jive")
|
|
|
|
I don't feel like dancing Jive.
|
2007-09-22 00:19:20 +08:00
|
|
|
|
|
|
|
# Invoke a command that doesn't exist
|
|
|
|
>>> management.call_command('explode')
|
|
|
|
Traceback (most recent call last):
|
|
|
|
...
|
|
|
|
CommandError: Unknown command: 'explode'
|
|
|
|
|
2009-04-06 01:27:26 +08:00
|
|
|
# Invoke a command with default option `style`
|
|
|
|
>>> management.call_command('dance')
|
|
|
|
I don't feel like dancing Rock'n'Roll.
|
2007-09-22 00:19:20 +08:00
|
|
|
|
2007-12-02 05:18:45 +08:00
|
|
|
"""}
|