Forums

Trouble running a python file for a scheduled task with a django app.

Sorry I am new to django, and pythonanywhere. I am trying to run a python script on a scheduled task to update django-haystack. I have tried following the wiki at https://www.pythonanywhere.com/wiki/ScheduledTasks, but still am not sure how to format the set up for the task. The app is built on python3.3, and the file I am trying to run is located at /home/<user>/<mysite>/myscript.py. Any suggestions or examples of how to set up the task will be appreciated. Thanks

Does

python3 /home/myusername/mysite/myscript.py

not work?

it should be as simple as putting the file path of the script you want to run like harry^ suggested. although i had a bit of trouble with django. not sure if it helps but you cant access a django model object from any .py file in your directory like you can in 'views.py'. have a look at: https://docs.djangoproject.com/en/dev/howto/custom-management-commands/ also you might want to bear in mind if your using a virtualenv: https://www.pythonanywhere.com/forums/topic/1447/ final point. what do you actually mean by 'updating django haystack'?

Thanks for the help! What harry posted works, and everything is great.