Thursday, November 20, 2014

adding commands to manage.py (if you don't like the shell < script.py trick)

Say you want to do something periodically that will affect your django environment (like check email).  You can schedule a task to do that using cron.  But that task needs to be run within your django environment.

One way to do that is to use

python manage.py shell < script.py

(or, if you have your permissions altered via chmod +x, 

./manage.py shell < script.py

)

It works.

If you want to get fancier, you can make a custom command for manage.py:

https://docs.djangoproject.com/en/dev/howto/custom-management-commands/

No comments:

Post a Comment