Forums

Unhandled Exception: can't find module

I really like the look of this site. I've just started with Django, and hadn't imagined there would be something this convenient.

But, on my first attempt, I can't get my web app to work: having copied all the files onto the server and followed the tutorial - http://tutorial.pythonanywhere.com/django#existing-apps-manual-config - to the letter, the page just shows the words 'Unhandled Exception'. Reading the error log, I see this:

ImportError: Could not import settings 'myapp.settings' (Is it on sys.path?): No module named myapp.settings

I've replaced all the paths I could find in the settings.py and the wsgi file thing, and will freely admit to being out of my depth here. Don't know why it can't find settings.py. If I was a computer, I bet I could find it.

Hello evilkillerfiggin!

Welcome aboard and all that stuff. Right. The place where we need to set the system path, so that our crafty computers can find your settings.py file is inside the wsgi.py file for your app. i.e this file (don't worry that link won't work for anyone but you). Inside that file you need to set the path to the top level of your Django application.

If your application lives in /home/evilkillerfiggin/myapp then you need to set the path to /home/evilkillerfiggin/myapp. Anything else is wrong and won't work.

Gotcha. I had mine pointing at the actual settings file.

Now I have the page loading, and giving me an ImportError, "cannot import name patterns"

Wouldn't know what to do about that. In my urls.py, I have

from django.conf.urls import patterns, include, url

I'd assume it should know what django.conf is automatically?

I've been poking about, but can't see anything. It all works on my machine, so do I just need to change something in settings.py? The only thing I can think of is ROOT_URLCONF = 'myapp.urls'. But that's pointing to the right place already.

could this be a difference between version 1.3 and 1.4? I think you need:

from django.conf.urls.defaults import patterns, include, url

Next error says, No module named critique.models

I get the impression there's going to be a lot of these.

The error page says, Django Version: 1.3.4. On my machine it's 1.4.2. Is there any way to change versions? At the moment I'm attempting to back-migrate the whole thing to 1.3 without any understanding of what I'm doing and it's hell.

Also, what time zone are you guys in and what hours are you checking this forum? I don't mind staying up all night and getting this fixed; taking twelve hour turns to talk is gruelling.

Okay, tweaked and fiddled with stuff until it worked. Hooray.

Might be tedious trying to remember which little changes I have to make where, every time I upload a new version. But at least now I have some progress to show.

We're in the UK, and we always check the forums from about 10am to around 7pm -- sometimes outside those hours, but less over the weekend. If you want to use Django 1.4 on PythonAnywhere, there are some useful hints in this forum thread.