Running Google App Engine Helper trunk with Django trunk (zipimport)

Dan Sanderson has a good article on Google Code on Using Django 1.0 on App Engine with Zipimport, however it misses two steps in preparing the django.zip file if you want to use the latest Django trunk with the latest Google App Engine Helper.

To create a new Django application for Google App Engine using Google App Engine Helper, start by exporting the latest Google App Engine Helper:

svn export http://google-app-engine-django.googlecode.com/svn/trunk/ ~/myapp

To create a django.zip file to use with the latest Google App Engine:

  1. Export the latest Django trunk
    svn export http://code.djangoproject.com/svn/django/trunk/ django
  2. Follow steps #2 and #3 in Dan's instructions under the "Archiving Django 1.0" section of his article
  3. Add contrib/auth:
    zip -r django.zip django/contrib/__init__.py \
    	                  django/contrib/auth
  4. Add contrib/sessions:
    zip -r django.zip django/contrib/__init__.py \
    	                  django/contrib/sessions
  5. Copy the django.zip file into the root folder of your new app:
    cp django.zip ~/myapp
  6. Uncomment the sessions middleware or auth middleware lines in settings.py file in your app so that it looks like:
    MIDDLEWARE_CLASSES = (
          'django.middleware.common.CommonMiddleware',
          'django.contrib.sessions.middleware.SessionMiddleware',
          'django.contrib.auth.middleware.AuthenticationMiddleware',
      #    'django.middleware.doc.XViewMiddleware',
    	)

That's it! To test it out:

./manage.py runserver

Hit http://localhost:8000/ and you should see the default Django welcome page.

Update: Don't make the mistake of adding django.contrib.auth or django.contrib.sessions to your INSTALLED_APPS, even though you are including those apps in the django.zip file. If you do, ./manage.py runserver will work but ./manage.py shell and ./manage.py flush will return errors.

Comments