AppRegistryNotReady error - Django 1.7 with pythonanywhere



Although pythonanywhere offers a good hosting, for some reason they use old version of Django by default, so we have to use virtual environment to install newer version.

The problem is that they are using an old version of WSGI, which (in my case) was giving this annoying error. After wasting a lot of time looking around for a solution, I figured out that pythonanywhere does not use the WSGI from my django project, they are using their own. So I went there and they where using a old code the should be replaced.

They have something like:
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
I replaced it with the below and it worked:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Resources:
https://docs.djangoproject.com/en/1.8/releases/1.7/

Comments

Popular Posts