Forums

Error deploying Django Application

I have created a Django weather app and I would like to host it online. Iam unable to deploy my application on pythonanywhere. Any help will be greatly appreciated.

This is my app's structure:

 myapp3.py  (main directory)
├── manage.py 
├── myweatherapp (sub directory)
 ├── __init__.py 
 ├── settings.py 
 ├── urls.py 
 └── wsgi.py 
└── myapp  (sub directory)
├── __init__.py 
├── models.py 
├── tests.py 
└── views.py 
└── templates  (sub directory)
└── static (sub directory)

This is what I have in the "weather_pythonanywhere_com_wsgi.py ":

import os
import sys

path = '/home/weather/myapp3/myweatherapp/settings.py'
if path not in sys.path:
    sys.path.append(path)

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myweatherapp.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Error log:

2015-03-24 23:58:17,619 :ImportError: No module named wsgi
2015-03-24 23:58:18,290 :Traceback (most recent call last):
2015-03-24 23:58:18,290 :  File "/bin/user_wsgi_wrapper.py", line 130, in __call__
2015-03-24 23:58:18,291 :    self.error_log_file.logger.exception("Error running WSGI application")
2015-03-24 23:58:18,291 :  File "/usr/lib/python2.7/logging/__init__.py", line 1185, in exception
2015-03-24 23:58:18,291 :    self.error(msg, *args, **kwargs)
2015-03-24 23:58:18,291 :  File "/usr/lib/python2.7/logging/__init__.py", line 1178, in error
2015-03-24 23:58:18,292 :    self._log(ERROR, msg, args, **kwargs)
2015-03-24 23:58:18,292 :  File "/usr/lib/python2.7/logging/__init__.py", line 1270, in _log
2015-03-24 23:58:18,292 :    record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
2015-03-24 23:58:18,292 :  File "/usr/lib/python2.7/logging/__init__.py", line 1244, in makeRecord
2015-03-24 23:58:18,292 :    rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
2015-03-24 23:58:18,293 :  File "/usr/lib/python2.7/logging/__init__.py", line 284, in __init__
2015-03-24 23:58:18,293 :    self.threadName = threading.current_thread().name
2015-03-24 23:58:18,293 :  File "/usr/lib/python2.7/threading.py", line 1160, in currentThread
2015-03-24 23:58:18,293 :    return _active[_get_ident()]
2015-03-24 23:58:18,293 :  File "/bin/user_wsgi_wrapper.py", line 122, in __call__
2015-03-24 23:58:18,294 :    app_iterator = self.app(environ, start_response)
2015-03-24 23:58:18,294 :  File "/bin/user_wsgi_wrapper.py", line 136, in import_error_application
2015-03-24 23:58:18,294 :    raise e
2015-03-24 23:58:18,294 :ImportError: No module named wsgi

I has the same error, I solved creating a virtualenv.. Try it!

It looks like you may be trying to use the wrong version of Django. The most likely cause is that you're using the default Django for Python 2.7 which is quite old. Have a look at this for instructions on using a virtualenv for updating Django.

I created the virtualenv, added the path and also updated the python version to 3.4. Now I don't get any errors but the site does not load.

When I try to hit your web app, I get a redirect loop. Your root URL is redirecting to your root URL, so it just runs in a circle until the browser gives up.