| | 606 | |
|---|
| | 607 | Customized actions |
|---|
| | 608 | ================== |
|---|
| | 609 | |
|---|
| | 610 | **New in Django development version** |
|---|
| | 611 | |
|---|
| | 612 | If you want to add an action of your own to ``manage.py``, you can. |
|---|
| | 613 | Simply add a ``management/commands`` directory to your application. |
|---|
| | 614 | Each python file in that directory will be discovered and registered as |
|---|
| | 615 | a command that can be executed as an action when you run ``manage.py``:: |
|---|
| | 616 | |
|---|
| | 617 | /fancy_blog |
|---|
| | 618 | __init__.py |
|---|
| | 619 | models.py |
|---|
| | 620 | /management |
|---|
| | 621 | __init__.py |
|---|
| | 622 | /commands |
|---|
| | 623 | __init__.py |
|---|
| | 624 | explode.py |
|---|
| | 625 | views.py |
|---|
| | 626 | |
|---|
| | 627 | In this example, ``explode`` command will be made available to any project |
|---|
| | 628 | that includes the ``fancy_blog`` application in ``settings.INSTALLED_APPS``. |
|---|
| | 629 | |
|---|
| | 630 | The ``explode.py`` file has only one requirement -- it must define a class |
|---|
| | 631 | called ``Command`` that extends ``django.core.management.base.BaseCommand``. |
|---|
| | 632 | |
|---|
| | 633 | For more details on how to define your own commands, look at the code for the |
|---|
| | 634 | existing ``django-admin.py`` commands, in ``/django/core/management/commands``. |
|---|