Converting a Django site to Google App Engine
Since my company was acquired, I needed to get my website off of the new company’s servers. My site was built with Django, and I didn’t want to have to pay for hosting.
I was at the same time reading a book on Google App Engine (GAE), and realized this would be a great fit. GAE offers generous initial quotas for free and I think I can fit within the free quota limits of GAE for a while. The free quotas equate to 1 GB of persistent storage and enough CPU and bandwidth for about 5 million page views a month.
As of a few days ago, the site was fully converted to a live GAE site. The page you are reading was served from GAE.
The entire conversion process only took a day and a bit for bug fixing, including coding an administrative back-end. To import the data from the old site I used the GAE shell which interfaced into sqlite and my local GAE instance, and then used the GAE bulk exporter from my local datastore and bulk importer to the remote datastore. Alternatively, I could have used the Remote API if I wanted to go directly to the remote site. If this all sounds foreign to you, and you are interested in GAE, buy the book from the review below!
As most Django websites, my existing site was based on a relational database (in particular sqlite). You can’t use relational databases with GAE, so most of the work in converting the site was in converitng the Django models and queries to the datastore’s equivalents. In particular I had to re-code the blogs database, comments, tags, and syndication using Google’s datastore and GQL.
In addition, the Django administration console didn’t work since it relies heavily on the database back-end. I made a small administration section myself using Django forms.
GQL by the way looks exactly like SQL, but doesn’t allow joins, and can’t select partial entities which exist in your datastore.
GAE doesn’t support Django 1.3 yet, so I used 1.2 and the Google App Engine Django project. The Google App Engine Django project interops GAE with Django easily. I was using Django 0.96 on my old site so this was already an improvement. The Google App Engine Django project is a great project which allows access to many Django features including using manage.py, sending mail, and Django’s test framework.
The only downside of GAE is that if Google ever stops offering their service, I’d need to go through another conversion. There are already several replacement systems though which implement the same platform that you can host yourself, although I’ve heard all are still missing some functionality.
After watching the launch videos of Google App Engine at Google Campfire (6 part video), I was surprised to hear that Guido van Rossum works on the Google App Engine team. Apparently 50% of his time is still spent working on managing the Python language itself.