views:

51

answers:

1

I am a newbie with a problem working with Django-nonrel on Google App Engine.

I created a new app called "helloapp".

1) I have created a view in views.py called hello world:

from django.http import HttpResponse

def hello(request):
     return HttpResponse("Hello world")

2) I have then linked to it in the urls.py using:

from django.conf.urls.defaults import *
from helloapp.views import hello

urlpatterns = patterns('',
     (r'^hello/$',hello),
)

This works fine locally, but on live I am getting 500 Server error.

In the GAE logs I see that I am getting an import error

ImportError: No module named helloapp.views

This is confusing since, as mentioned, this works fine locally.

Help.

A: 

Maybe try this:

from views import hello

Locally your views.py is in a helloapp directory. But when it gets uploaded onto app engine it is placed into a directory with a version number like this, where helloapp.views does not exist:

/base/data/home/apps/helloapp/1.23456789/views.py

Saxon Druce
Thanks that fixed it. Can't believe I didn't try that before. :)
iali