Forums

Newbie Django tutorial - not getting the Django rocket page

I'm new to PythonAnywhere and Django. I have been following the Django newbie tutorial and the PythonAnywhere readalong page here and here.

So, I get to the part where I edit the mysite/mysite/wsgi.py... and when I reload my app on the Web tab and visit razors.pythonanywhere.com I get the PythonAnywhere default page that reads "Hello, World! This is the default welcome page for a PythonAnywhere hosted web application." NOT the Django default page with the rocket.

I have followed the 2 sets of instructions correctly I think, so I don't know what I need to do to fix this.

Can anyone help me out please?

The wsgi file in your mysite directory is not the one that determines what code is run, the one that is linked to from your web app configuration is. Follow the instructions for editing the wsgi file on your second link, except edit the wsgi file on your web app configuration page.

Thanks for that. I figured the file I need to edit is at : /var/www/razors_pythonanywhere_com_wsgi.py.

Unfortunately, after deleting the code already there and replacing it with the code in the tutorial read-along, I reload the app then go to its url, and I get the "Something went wrong page." It tells me the problem is: "Unhandled Exception".

The error log says:

2020-01-15 16:52:30,108: Error running WSGI application 2020-01-15

16:52:30,112: ModuleNotFoundError: No module named 'django' 2020-01-15

16:52:30,112: File "/var/www/razors_pythonanywhere_com_wsgi.py",

line 25, in <module> 2020-01-15 16:52:30,112: from

django.core.wsgi import get_wsgi_application 2020-01-15 16:52:30,112: ******* 2020-01-15 16:52:30,113: If you're seeing an import error and don't know why, 2020-01-15 16:52:30,113: we have a dedicated help page to help you debug: 2020-01-15 16:52:30,113: https://help.pythonanywhere.com/pages/DebuggingImportError/ 2020-01-15 16:52:30,113: ******* 2020-01-15 16:52:35,790: Error running WSGI application 2020-01-15 16:52:35,791: ModuleNotFoundError: No module named 'django' 2020-01-15 16:52:35,791: File "/var/www/razors_pythonanywhere_com_wsgi.py", line 25, in <module> 2020-01-15 16:52:35,792: from django.core.wsgi import get_wsgi_application 2020-01-15 16:52:35,792: ******* 2020-01-15 16:52:35,792: If you're seeing an import error and don't know why, 2020-01-15 16:52:35,792: we have a dedicated help page to help you debug: 2020-01-15 16:52:35,793: https://help.pythonanywhere.com/pages/DebuggingImportError/ 2020-01-15 16:52:35,793: *******

What should I do?

Please disregard the above, I fixed it by editing the correct wsgi file, installing django to my virtualenv (I forgot!) and adding 'razors.pythonanywhere.com' to ALLOWED_HOSTS. Now I'm getting the default rocket page!!

Excellent, glad you worked it out!