Forums

Looking for help on a first setup

I'm a little frustrated, I wrote a Django app in about two hours, but i've been struggling with PythonAnywhere for three !

I'd be really glad if you could help out.

Currently, I'm getting an Error code: Unhandled Exception when going to my domain. I suspect my WSGI file is not properly configured. I'm (trying to) use Django 1.7 and Python 3.4.

Server error log ends with :

django.core.exceptions.ImproperlyConfigured: Module "django.contrib.auth.middleware" does not define a "SessionAuthenticationMiddleware" attribute/class

Here is my WSGI :

activate_this = '/home/antoningrele/.virtualenvs/django17/bin/activate_this.py'
with open(activate_this) as f:
    code = compile(f.read(), activate_this, 'exec')
    exec(code, dict(__file__=activate_this))

# +++++++++++ DJANGO +++++++++++

import os
import sys

path = '/home/antoningrele/.virtualenvs/django17/electorcollector/'
if path not in sys.path:
    sys.path.append(path)

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

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

#   import django
#   django.setup()

Please feel free to look inside the rest of my installation if need be, there's nothing confidential in there.

Your web app is for Python 3.4 and the virtualenv you're using has Django 1.7 installed for Python 3.3, so when your app runs under Python 3.4, it's using the system-installed Django which is version 1.6.6.

I see, thank you.

I reinstalled the virtualenv in Python 3.3. I now get the following error :

ImportError: Could not import settings 'electorcollector.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named 'electorcollector.settings'

My settings.py is in :

.virtualenvs > django17 > electorcollector > electorcollector > settings.py

From your error logs, it looks like you fixed that one (or you're misreading the error log). You issue now is:

django.core.exceptions.AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time.

See here for troubleshooting.

I added the following, as suggested in your help wiki, which worked :

import django
django.setup()

Thanks a lot :)