Tuesday, November 5, 2013

The following note is taken while I follow django-nonrel installation document to setup django-nonrel for Google app engine. My development environment is Apple OSX.


Download django-nonrel

Several zip files are needed from the following repositories:
After downloading the zip files, I unzip them into the directory django-nonrel in my home directory. The end result is the following:
     $ ls -F ~/django-nonrel
     django-dbindexer-dbindexer-1.5-beta/
     django-testapp-testapp-1.5-beta/
     djangotoolbox-toolbox-1.5-beta/
     django-nonrel-1.5-beta/
     djangoappengine-appengine-1.5-beta/
     twanschik-django-autoload-1698ab544030/


Setup the Django project

Next I have to deviate from the common way of creating Django project. Instead of django-admin.py startproject, the following steps are used:
  1. Copy the django-nonrel test application directory to the project directory. My project directory name is DjangoNonrel:
    $ cd ~/DjangoProjects
    $ cp -R ~/django-nonrel/django-testapp-testapp-1.5-beta DjangoNonrel
  2. Configure django-nonrel for the newly created project:
    $ cd ~/DjangoProjects/DjangoNonrel
    $ ln -s ~/django-nonrel/django-nonrel-1.5-beta/django/ django
    $ ln -s ~/django-nonrel/django-dbindexer-dbindexer-1.5-beta/dbindexer/ dbindexer
    $ ln -s ~/django-nonrel/djangotoolbox-toolbox-1.5-beta/djangotoolbox/ djangotoolbox
    $ ln -s ~/django-nonrel/twanschik-django-autoload-1698ab544030/autoload/ autoload
    $ ln -s ~/django-nonrel/djangoappengine-appengine-1.5-beta/djangoappengine/ djangoappengine
A quick sanity check is due. I start the server the usual way,
$ ./manage.py runserver
then load http://localhost:8000/ to the web browser. The rendered page contains the "It works!" heading. Everything seems to work so far.

Deploy to Google App Engine

Time to try out the real target - the Google app engine. Here's what works for me:
  1. Go to http://appengine.google.com/ to create a Google app engine application. What matters at this point is the name of the application. I name my application "django-on-gae".
  2. Enter the application name to app.yaml. The first line of my app.yaml is:
    application: django-on-gae
  3. Since the Google app engine applications are deployed to the domain ".appspot.com", this domain needs to be added to ALLOWED_HOSTS in ~/django-nonrel/django-nonrel-1.5-beta/django/conf/global_settings.py. I set mine to this:
    ALLOWED_HOSTS = ['.appspot.com']
  4. Deploy the application to Google app engine:
    $ ./manage.py deploy
The same sanity check is now repeated on Google app engine. The page http://django-on-gae.appspot.com/ rendered the same "It works!" page. Yeah!