Django: Management Command Disappeared and I can't test the script

541 views Asked by At

I had a command all set up and working, then I set up a Cron job for it and now it disappeared from manage.py help's list of all available commands.

It is under /app/management/commands/feed_update.py

and it has a Command(BaseCommand) class with a handle() function.

The problem is that my script has dependencies to app.models so I can't even run the script to see if something is wrong and why manage.py won't pick it up automatically.

Is there a way to force manage.py to find the script?

Thanks.

Edit 1: I just tried doing

manage.py shell

>> import app.management.commands.feed_update as fu
>> fu.Command.handle(fu.Command())

and everything worked fine. I just don't understand why it wont let me run it through manage.py

I have __init__.py files in every folder..

Edit 2: The app is installed in Settings.py and is my main app that serves my web content so I am absolutely certain it is installed.

It can't find the command either in Cron or when I go in through the terminal (even though my other apps' Commands show up correctly).

2

There are 2 answers

1
Daniel Roseman On

It needs to be inside an application that is listed in settings.INSTALLED_APPS.

If it seems to be there already, are you sure that the cron job is using the right settings.py?

0
Tim Fletcher On

I just solved a problem almost identical to this except I'm using django-admin.py. A management command which worked perfectly on my dev machine wasn't appearing in the list of commands shown when you run django-admin.py without an argument. Turns out you need to run django-admin.py from within the root folder of your project if you want custom management commands to work.