Forums

Django - BaseCommand - Schedule

Hello,

I made a stock_notification BaseCommand in my Django app, and I am able to execute it successfully but I can't schedule it.

Manually, to have it works, I need to activate my virtual environment first. So I do this : source myenv/bin/activate and at the root : python /home/<user>/<project>/manage.py stock_notification and it works fine.

But if I schedule python /home/<user>/<project>/manage.py stock_notification, nothing happens (error : Unknown command: 'stock_notification').

How I can fix my issue ? Antoine.

Is this because you are not using your virtualenv python? When you have activated your virtualenv, do a which python in the console to see the path of your virtualenvpython (eg: /home/user/.virtualenvs/myvirtualenv/python) and use /home/user/.virtualenvs/myvirtualenv/python /home/<user>/<project>/manage.py stock_notification instead?

Thanks a lot it works well.