Forums

Not getting the Django rocket page with Python 3.8 and Django 3.17

I'm new to PythonAnywhere and Django. I have been following the Django "Poll project on PythonAnywhere" tutorial and "Following the official Python tutorial on PythonAnyshere".

I have done partially this project before, with Python 3.9 and Django 3.16" and completed 3 to 4 parts successfully.

This time, I stuck in the start and NOT getting the Django default rocket page after installing and configuring as mentioned in the project instructions. I get to the part where I edit mysite/mysite/wsgi.py and checked it at least 5 times for any typo. I also edit mysite/mysite/setting.py and changed ALLOWED_HOST = ['*'] as well as I also tried with ['asansari.pythonanywhere.com']. After loading the page, I can get to the 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.

My codes for wsgi.py

import os
import sys

path = os.path.expanduser('~/mysite')
if path not in sys.path:
    sys.path.insert(0, path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

from django.core.wsgi import get_wsgi_application
from django.contrib.staticfiles.handlers import StaticFilesHandler

application = StaticFilesHandler(get_wsgi_application())

Line in settings.py

ALLOWED_HOSTS = ['asansari.pythonanywhere.com']

Is it the new version of Django 3.17! or something I am missing?

Please help me! I will appreciate it. Thanks.

I think you're editing the wrong WSGI file -- you should not change the one inside your Django code, but instead the one that is linked from the "Web" page inside PythonAnywhere (which is located in /var/www). If you copy the contents of the WSGI file that you have been editing into that one, then reload the website using the button on the "Web" page, everything should work fine.

It worked! Thanks a lot and a lot of appreciation.

Glad you got that working!