Blog posts tagged: django
News and other things I find interesting
Converting a Django site to Google App Engine
Last modified: Sunday, May 01, 2011
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.
Tags: python django google-app-engine
Add a new comment | 2 comment(s)
|
Have you heard of Django-nonrel? It supports Django models, the admin UI and a lot of other Django features, so you could've reused much more code. |
|
Ya I actually mentioned the non rel project in my critique of the GAE book in my previous blog post. It seems further ahead than the Google App Engine Django project which I used and which the book recommended. I wanted to get a tighter feel for GAE and the datastore anyway though, so I didn't mind. |
Review of Programming Google App Engine
Last modified: Tuesday, October 11, 2011
★★★★☆ (4 stars out of 5)
I purchased the Programming Google App Engine book by Dan Sanderson because I wanted to learn more about Google App Engine (GAE) on Python.
GAE is a platform and set of services for building web applications.
GAE scales your web application automatically as long as you work within their set of restrictions such as using a non relational datastore.
Although the online GAE doc has great coverage and documentation, I wanted something which could provide a little more depth. Looking up things as you need them in the GAE docs doesn't give you a high level global understanding of what's possible and how to do it.
I am left feeling confident coding for GAE after reading this book. The author has a great understanding of GAE and does a great job of explaining everything clearly. I was never bored when reading this book and the examples were great dealing with game avatars.
After reading this book you will be ready to take on a GAE project to solidify the knowledge you learnt. You will have a great understanding of GAE runtime, datastore, index design, datastore transactions, memcache, queues, scheduled tasks, webapp module, django on GAE, remote API, bulk data operations, incoming/outgoing email, incoming/outgoing XMPP and more.
You will also understand exactly what will never be possible on this platform (such as writing to the filesystem), and what will one day be possible (such as different languages and runtimes).
This book is a quick read, it is 333 pages not including the index, and if you are only interested in Python you will be skipping over about 1/3 of the book. I would have preferred if the book only focused on Python and didn't even mention Java. I would have preferred the book to be split into 2; a python version and a Java version.
In the one and a half years since the book was released, and since GAE was released April 7, 2008, there are already several additions to GAE, but everything mentioned in the book is still sound. The book will give you enough of a foundation of Google App Engine to continue on.
I hope future editions will include coverage on OAuth, Prospective Search, DoS Protection, the django nonrel project, and updated content throughout
Tags: django google-app-engine book review python
Add a new commentDjango tagging
Last modified: Friday, April 22, 2011
I added tags support for my blog posts via using the Django tagging library. As you can see each blog post now has any number of tags associated with them.
Overall Django tagging works a lot like Django comments in that you can attach tags to any model in your project.
To implement Django tagging inside my site, I did need to make a slight model change to have a tags field in my blog news item table. Apparently this field is only used for caching and so that it shows up in the Django administration. When you modify your model in Django administration a new text field appears labeled Tags that you can enter in space separated tags for your model.
I made each tag into a link which bring you to all posts on the site about the specified tag. Also you can find a Tags link on the right hand bar which displays the list of tags in use and how many posts each tag has.
The Django tagging framework has many other features which I didn't use, but from what I used it's a great and very easy to use library.
The new site is out!
Last modified: Friday, April 22, 2011
Several months ago I decided that this website needed a revamping.
The work since that thought is finally being released today. The work on the site is still slowly in progress, but I feel that enough of the site is done to be better than the last site.
Some stats on the new site:
- Was developed on my mac
- Was written using vi for all editing
- Was built using Django 1.1
- Is running with Python 2.6
- Is served through IIS with PyISAPIe. (PyISAPIe is a great project created by Phillip Sitbon which brings Django to IIS.)
- JQuery was used for a couple of post page served alterations
- The database is built using SQLite
- The blog posts with code samples are made with Google's code prettify
- All blog posts are rendered using Django Markdown (which makes for easy posting of great content)
Markdown is a hassle free, easy to use markup language that allows you to easily post links, post images, and format great blog posts with little work.
The old site was built in ASP .NET beta, and slowly upgraded over time to newer versions. Overall for me, coding in Django is a much better and funner experience than coding in ASP .NET ever was.
Before deciding on Django for the new site, I also had an attempt at Ruby on Rails. I wasn't a fan from the start, the language was simply too different from what I am used to and know.
I like the new design a lot better than the old one. I hired Bradd Bezaire to do this design over 2 years ago in August of 2007. This design sat in my inbox since then because I've been extremely busy, but I'm glad his work didn't go to waste after all.
PyISAPIe with Django 1.1 and Python 2.6
Last modified: Friday, April 22, 2011
The PyISAPIe help files currently claim you have to use Python 2.5 and uses Django pre 1.0.
But with some small changes to one of the config files, you can actually have Django 1.1 and Python 2.6.
The only change from their help file that you need to do is replace their pyisapie.py with this file that I modified.
