Wednesday, March 10, 2010

Django Nonrel and Google App Engine

The guys behind appengine patch have a new project using the Django nonrel project to run on App Engine.

Clone the appropriate projects from bitbucket :
$ hg clone https://[Bitbucket User Name]
$ hg clone https://[Bitbucket User Name]
$ hg clone https://[Bitbucket User Name]

The instructions say next, "Now you should be able to create a new app in the testapp folder and use native Django models on App Engine. Try it!"

dignan@dignan-laptop:~/workspace/django-nonrel/django-testapp$ python runserver
Traceback (most recent call last):
File "", line 4, in <module>
from djangoappengine.boot import setup_env
ImportError: No module named djangoappengine.boot

The documentation calls for two symlinks :
django-testapp/common-apps/djangoappengine -> ../../djangoappengine
django-testapp/common-apps/djangoappengine -> ../../django-nonrel/django

I created them and tried again.
The Google App Engine SDK could not be found!
Make sure it's accessible via your PATH environment.
So I added the it to my path and tried again. Same result.

I found the following on the appengine-patch website:
"you can also put the SDK into any folder that is in the system's PATH environment variable as long as it's called "google_appengine" (this works with any OS)"

My sdk was in "google_appengine_1.3.0". I created a symlink, "google_appengine" and tried again.

/home/dignan/tools/appengine/google_appengine_1.3.0/google/appengine/api/ DeprecationWarning: the md5 module is deprecated; use hashlib instead                                                             
import md5
/home/dignan/tools/appengine/google_appengine_1.3.0/google/appengine/api/memcache/ DeprecationWarning: the sha module is deprecated; use the hashlib module instead
import sha
WARNING 2010-03-10 22:41:09,468] Could not read datastore data from /tmp/django_nonreltest.datastore
Traceback (most recent call last):
File "workspace/django-norel/django-testapp/", line 16, in <module>
File "/home/dignan/workspace/django-norel/django-testapp/common-apps/django/core/management/", line 438, in execute_manager
File "/home/dignan/workspace/django-norel/django-testapp/common-apps/django/core/management/", line 379, in execute
File "workspace/django-norel/django-testapp/common-apps/djangoappengine/management/commands/", line 88, in run_from_argv
File "workspace/django-norel/django-testapp/common-apps/djangoappengine/management/commands/", line 74, in start_dev_appserver
dev_appserver_main.main([progname] + args + [os.getcwdu()])
File "/home/dignan/tools/appengine/google_appengine_1.3.0/google/appengine/tools/", line 360, in main
config, matcher = dev_appserver.LoadAppConfig(root_path, {})
File "/home/dignan/tools/appengine/google_appengine_1.3.0/google/appengine/tools/", line 3441, in LoadAppConfig
raise AppConfigNotFoundError

At least it started! I cd'd into the app's directory and ran:

python runserver

It started up. I got the default "It worked!" page.


adrián said...

hi, there is a mistake in the django softlink. They should be:

django -> ../../django-nonrel/django/

djangoappengine -> ../../djangoappengine

In case readers do not know how to create them:

cd django-testapp/common-apps$

ln -s ../../django-nonrel/django/ django

ln -s ../../djangoappengine djangoappengine

ugn said...

simple step by step guide
without mistakes

Mike said...

What's the best way to handle those links if you're on a Windows system, where symlinks don't work?

jeremyrdavis said...


I don't have a good answer offhand.
I am not as familiar with Windows and don't have a Windows machine at home to try anything out.

You can copy the "django" and "djangoappengine" folders into the "common-apps" folder. I don't know what that will do in production though.

I haven't been using django-nonrel much since discovering the kay framework.

kay framework is essentially a port of django to appengine. A lot of Django's functionality exits, and the project is under very active development. I highly recommend checking it out.

ugn said...

for Win symlinks

CLM said...

For windows file links you can use "junction"