Roy Tang

Programmer, engineer, scientist, critic, gamer, dreamer, and kid-at-heart.

Blog Notes Photos Links Archives About

Django and Google App Engine

In my continuing quest to become better than everybody else, I spent some time today learning Django (a Python webapp framework) and the Google App Engine.

I tried following the tutorials included in the Django Book for a while, but I’ve never taken too well with just typing up examples from a book, so I decided to write something from scratch. I decided to write a simple message board application.

I wrote the message board pretty quickly using Django; it took me about 2-3 hours to have a bare-bones message board up and running. (I was watching Speed Racer at the same time.) The UI is horrendous of course, but it’s functional, with categories and topics, etc.

Now to deploy the message board app somewhere. After a bit of searching around, I couldn’t find any suitable free Django webhosting. So I went with the backup plan: I’d upload the project to the Google App Engine.

I’ve had a Google App Engine account for a while now, but haven’t done anything with it yet. Unfortunately, a Django app can’t be ported directly to GAE as Google has their own datastore implementation which won’t work with Django’s models. So I spent the rest of the day porting/rewriting the message board app for use with GAE. Google has their own guide for this sort of porting here: Running Django on Google App Engine.

Some problems encountered when porting:

  • Can’t seem to use the list_detail generic view; I get errors about undefined user attribute on the request
  • Sometimes after editing a view, I get random “NoneType has no attibute get” errors. Restarting the dev_appserver fixes this.
  • Unlike Django, GAE models don’t have an “id” primary key. Instead, you must use object.key() which returns some sort of hash string (making for very inconvenient urls)
  • I’m having errors raised during 404s; the problem is mentioned in this thread which should already be fixed but I’m still encountering it. I’ll investigate it later.

The final product is here: Random Encounters Message Boards . I don’t know who would actually use the site, but I think there’s some people I know reading this blog who wouldn’t be able to resist testing it!

The next step would be to improve the UI of the app!

Posted by under post at #Software Development
/ 0 / 376 words

See Also