Google-App-Engine-Django Tutorial, Part 2 – Set up

Posted: July 13th, 2009 | By | Filed under: Development | Tags: , , , , | No Comments »

Edit 2014-01-23: The information on this post is extremely outdated! Please refer to the official App Engine cloudSQL documentation, or this article about using django-nonrel, or search for up to date information.

In this post, we’ll setup the environment needed to create and run a Google App Engine (GAE) application using Django and google-app-engine-django helper.

The procedures here are mostly covered in the excellent getting started article for GAE-D, which will likely be kept more up to date than this one. I will try to provide the exact setup process as I ran it, if anyone might find it useful.
I’m going to use Ubuntu Linux for this tutorial, because, well, that’s what I use. If there any difference refer to documentation of the different software, which i will try to provide.

Set up an App Engine Application

I won’t go through the details of this. All the following procedures, except uploading the application to GAE can be achieved without it, but in the end of the day, you’d want to use some of google’s CPU cycles, no?
Basically you have to sign up to GAE, Activate the account with an SMS activation code, and then create a new application. All this is done using very simple wizards. I have to note that when I named the application, almost any combination of number words was taken. Strange, but I don’t think it matters that much. An Application name like dobo_hellodjango would be good enough.

Setting up the django + GAE project

You will want (and need) to run python 2.5, as this is the runtime that GAE uses. While I managed to experiment locally with python 2.6, it throw outs lots of errors, and it’s not compatible with what is going to run eventually.
Install python any way you like, i did:

$ sudo apt-get install python2.5

Next, let’s create a folder for our various packages and expiriments. I’m going to use /home/amitay/dev/appengine.

cd /home/amitay/dev
mkdir appengine
cd appengine

Keep in mind that the following terminal commands assume that you’re in that directory.
now, download the GAE python SDK (the zip version if you’re using linux) to that folder.

Back to the terminal, unzip it:

$ unzip google_appengine_1.2.3.zip

Next thing, let’s get google-app-engine-django (GAE-D) directly from the repository using SVN. Yes, we’re doing bleeding edge development here. Wicked.
If you need SVN on ubuntu, you can simply run:

$ sudo apt-get install subversion

When SVN is installed, check out GAE-D trunk:

$ svn checkout http://google-app-engine-django.googlecode.com/svn/trunk/ google-app-engine-django

And now, we’ll export it to a new folder which will be our little secret project home.
“Export” means we’re creating an unversioned copy of GAE-D project, to be used as a basis for our project.
Note: I’m not going to deal, and i’m not sure myself, with how to update the GAE-D in your project with newer versions of it, I’m just following the GAE-D instructions. It seems to me a bit problematic that the trunk itself, and not something it generates is the template for your project.
Anyway, we were at exporting GAE-D, to a new folder for our project, which we’ll call “hellodjango”:

$ svn export google-app-engine-django hellodjango

We’ll need to create a link to in our project, on “.google_appengine” to the SDK we’ve previously downloaded and extracted:

$ ln -s /home/amitay/dev/appengine/google_appengine hellodjango/.google_appengine

(your absolute path may vary). Didn’t test it, but if the GAE SDK is installed in windows using the installer, this step can be skipped.

Now, we need to copy django 1.0 to a subfolder named “django” of our project. While the GAE-D readme states it works with “Django 1.0beta_1 or greater”, 1.1 versions from the django SVN trunk are not supported. So we’ll download the 1.0 stable version instead.
The following lines download django, unzips, and copy the django project directory to “hellodjango\django” directory”. You can do it manually too. If you’re a sucker.

$ wget http://www.djangoproject.com/download/1.0.2/tarball/
$ tar xzvf Django-1.0.2-final.tar.gz
$ cp -r Django-1.0.2-final/django/hellodjango/django

The project base should be ready now, So we’ll simply move its folder, and start up the development server to test it:

$ cd hellodjango/
$ python2.5 manage.py runserver 8009

manage.py is the management utility for Django. We’re running its “runserver” command, to start the development server on port 8009 (you can omit the port number, which will use the default 8080 port, which is simply used in my computer). notice i use “python2.5″ to interpret manage.py, this is simply because i have python 2.6 installed as well, and i want to use the supported version.
Ignore the WARNING messages you get regarding the datastore, they’ll disappear once we create some data.

If everything worked (crossing my fingers for you), you should now be able to browse to http://localhost:8009, and see the development server running.

Next Post I’ll go through writing some code in our application, and uploading it to Google App Engine, So it will forever live.

facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Leave a Reply