Django

Code

Changeset 5925

Show
Ignore:
Timestamp:
08/18/07 00:10:31 (9 months ago)
Author:
russellm
Message:

Added some initial documentation on adding customized commands to django-admin.py.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/django-admin.txt

    r5912 r5925  
    604604    * Type ``sql``, then [TAB], to see all available options whose names start 
    605605      with ``sql``. 
     606 
     607Customized actions 
     608================== 
     609 
     610**New in Django development version** 
     611 
     612If you want to add an action of your own to ``manage.py``, you can. 
     613Simply add a ``management/commands`` directory to your application. 
     614Each python file in that directory will be discovered and registered as 
     615a 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         
     627In this example, ``explode`` command will be made available to any project 
     628that includes the ``fancy_blog`` application in ``settings.INSTALLED_APPS``. 
     629 
     630The ``explode.py`` file has only one requirement -- it must define a class 
     631called ``Command`` that extends ``django.core.management.base.BaseCommand``. 
     632 
     633For more details on how to define your own commands, look at the code for the 
     634existing ``django-admin.py`` commands, in ``/django/core/management/commands``.