Forums

Deploy Problem

No matter how I change the WSGI file, the webpage always shows the hello world thing.

activate_this = '/home/davidzhao800/.virtualenvs/uTunes/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this)
import os
import sys

path = '/home/davidzhao800/uTunes'
if path not in sys.path:
   sys.path.append(path)
os.chdir(path)
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'uTunes.settings')
import django    
django.setup()
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

21:51 ~ $ workon uTunes

(uTunes)21:52 ~ $ ls

Dropbox README.txt uTunes

(uTunes)21:52 ~ $ cd uTunes

(uTunes)21:52 ~/uTunes $ ls

README.md Required SQL Queries SQLCode db.sqlite3 db_testing.txt manage.py store uTunes

(uTunes)21:52 ~/uTunes $ cd uTunes

(uTunes)21:52 ~/uTunes/uTunes $ ls

init.py init.pyc settings.py settings.pyc urls.py wsgi.py wsgi.pyc

(uTunes)21:52 ~/uTunes/uTunes $

I also add the virtualenv and static path already

And if I go into the app, davidzhao800.pythonanywhere.com/store/ the web is always loading

I solve the home page url and it worked, but it is still always loading. And the head of the page is "Web app setup:davidzhao800:Pythonanywhere". Is it normal that it is always loading? Should I wait or something is wrong?

That definitely doesn't sound normal. Let me take a look at our systems and see if there's anything obviously wrong. Would you mind if I took a look at your files? We can see them from our side but we always ask permission before looking.

OK, there's definitely one problem there -- you're using Python 3.4 for your web app, so the execfile thing you have at the start of your WSGI file won't work. I can see that you've already got the virtualenv that you want specified on the "Web" tab anyway, so you don't need those lines. (BTW where did you get those lines from? They were needed quite a long time ago, but we've updated the system now and you don't need them any more. Perhaps we need to update some documentation somewhere?)

If you remove the first two lines then reload the web app, it should work better. But let me know if it doesn't.

Thanks giles, you guys are quite helpful. Sorry for the late reply, I got some other deadlines these days. I got the start virtualenv code from other post in the forum. Anyway I have deleted them and reload. However, the page is still always loading and the head of the page is "Web app setup:davidzhao800:Pythonanywhere". Seeking for ur help.

Also, you can feel free to look at my code, it is from course project, not for commercial use.

You have a redirect loop (where your root page redirects back to itself) on your web app and each round takes a really long time (around 23seconds). I think the redirect loop may be because you've defined an empty url pattern in both uTunes/urls.py and store/urs.py that point to the same view.

Hi, glenn, Thank you for suggestion. I have commented the empty url pattern in utunes/url.py. and reloaded. So I just directly go to
http://davidzhao800.pythonanywhere.com/store/ while the page is still loading

It looks like the virtualenv you're using for the app was created for Python 2.7 (you can see if you run python --version while inside the virtualenv). Your web app is using Python 3.4, so I think everything's crashing before it manages to print out any error messages.

You should either:

  • Delete the virtualenv, and create a new one with the right version of Python, eg. mkvirtualenv --python=/usr/bin/python3.4 myvirtualenv
  • Or: delete the web app and create a new one using Python 2.7

Thx, giles, Sorry for late reply. I got exams last few days. According to ur last post, I think I have got things right. However, I still have trouble with unhandled exception. If you can help, please refer to my new post. Thanks a lot!