To expand on Van Gale's answer, it's most certainly possible. Here are the ingredients:
- An app that is in INSTALLED APPS
- The proper directory structure
- A python file to act as the command which inherits off of a Django management command class
Here's generally how this works...
When manage.py runs, if it does not find the command say "manage.py yui_compress" it searches through the installed apps. It looks in each app to see if app.management.commands exists, and then checks if there is a file "yui_compress.py" in that module. If so, it will initiate the class in that python file and use that.
So, it ends up looking like this...
app
\management
\commands
yui_compress.py
Where yui_compress.py contains...
from django.core.management.base import NoArgsCommand
class Command(NoArgsCommand):
help = "Does my special action."
requires_model_validation = False
def handle_noargs(self, **options):
# Execute whatever code you want here
pass
Of course 'app' needs to be in thE INSTALLED APPS inside of settings.py.
But then, Van does make a good suggestion to find a tool which already does what you want. :)