E
E
Egorian2018-07-18 16:24:55
Django
Egorian, 2018-07-18 16:24:55

Why aren't changes in _pythonanywhere_com_wsgi.py applied?

Followed this instruction.

(myenv) 13:17 ~/1website_v1 (master)$ pwd
/home/Goganoid/1website_v1
(myenv) 13:17 ~/1website_v1 (master)$ ls
README.md  db.sqlite3  jinjalesson  learntime  manage.py  media  static  tinymce  webexample
(myenv) 13:17 ~/1website_v1 (master)$

In learntime is settings.
This is how my _pythonanywhere_com_wsgi.py looks like:
HELLO_WORLD = """<html>
<head>
    <title>Python Anywhere hosted web application</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>
    This is the default welcome page for a
    <a href="https://www.pythonanywhere.com/">PythonAnywhere</a>
    hosted web application.
</p>
<p>
    Find out more about how to configure your own web application
    by visiting the <a href="https://www.pythonanywhere.com/web_app_setup/">web app setup</a> page
</p>
</body>
</html>"""


def application(environ, start_response):
    if environ.get('PATH_INFO') == '/':
        status = '200 OK'
        content = HELLO_WORLD
    else:
        status = '404 NOT FOUND'
        content = 'Page not found.'
    response_headers = [('Content-Type', 'text/html'), ('Content-Length', str(len(content)))]
    start_response(status, response_headers)
    yield content.encode('utf8')


# Below are templates for Django and Flask.  You should update the file
# appropriately for the web framework you're using, and then
# click the 'Reload /yourdomain.com/' button on the 'Web' tab to make your site
# live.

# +++++++++++ VIRTUALENV +++++++++++
# If you want to use a virtualenv, set its path on the web app setup tab.
# Then come back here and import your application object as per the
# instructions below


# +++++++++++ CUSTOM WSGI +++++++++++
# If you have a WSGI file that you want to serve using PythonAnywhere, perhaps
# in your home directory under version control, then use something like this:
#
#import sys
#
#path = '/home/Goganoid/path/to/my/app
#if path not in sys.path:
#    sys.path.append(path)
#
#from my_wsgi_file import application  # noqa


# +++++++++++ DJANGO +++++++++++
# To use your own django app use code like this:
import os
import sys

# assuming your django settings file is at '/home/Goganoid/mysite/mysite/settings.py'
# and your manage.py is is at '/home/Goganoid/mysite/manage.py'
path = '/home/Goganoid/1website_v1'
if path not in sys.path:
    sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'learntime.settings'

# then:
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

I have restarted the site.
But it gives somethin went wrong error.
Here is the error from the errorlog:
2018-07-18 12:19:25,781: Error running WSGI application
2018-07-18 12:19:25,789: ModuleNotFoundError: No module named '1website_v1.settings'
2018-07-18 12:19:25,789:   File "/var/www/goganoid_pythonanywhere_com_wsgi.py", line 22, in <module>
2018-07-18 12:19:25,789:     application = get_wsgi_application()

Why is the path '1website_v1.settings' used and not 'learntime.settings'?
Where could I mess up and how is it fixed?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question