Forums

How to upgrade Django version for Scheduled task.

I'm trying to set a schedule task in my django application.

So in my script, there is a line 'django.setup()'

But when executed, error message 'AttributeError: 'module' object has no attribute 'setup'' appears to me.

After searching for the solution, django.setup() is the method of version 1.7 of django.

Scheduled task's python version is 1.6.1.

How can I upgrade this and complete my purpose?

It looks like you're using a virtualenv in order to use Django 1.7 in your web app. So you can tell the scheduled task to use that virtualenv by running it using your virtualenv's Python executable.

So, let's say that the path that you're specifying on the "Web" tab is /path/to/virtualenv and the script you're running is /differentpath/script.py, then the scheduled task should run the command:

/path/to/virtualenv/bin/python /differentpath/script.py

@giles Thank you for answering me very much!!!! But I can not find the interface where I can command what you said '/path/to/virtualenv/bin/python /differentpath/scripts.py'

I did start my script with this sentence '#!/path/to/virtualenv/bin/python'... Isn't it right?

HELP !

When you set up a scheduled task, you enter a bash command. Right now that command is probably just the path to your script. Delete that task, and replace it with one that has the Python interpreter and then the path to the script, just as you would enter it on a bash command line.