About Me Contact Me Subscribe

I’ve been hanging out at the NYC App Engine Hackathon today and I’ve had some time to work on django-ae-utils.  Accordingly I’ve just posted an update to django-ae-utils.  This update includes a User model which uses the App Engine datastore as a backend, as well as a few generic views for working with the model.

Check it out at Google Code!

AddThis Social Bookmark Button

Recently I’ve started to play around with using Django on Google’s new App Engine.  As mentioned by many others at this point, Django technically runs on App Engine but there are significant parts which do not.  Accordingly I’ve started to write some code to replace or supplement the holes left in Django by App Engine.  Since I figure this code may be of use to others I’ve released it as an open-source project called django-ae-utils (github mirror coming soon).
(more…)

AddThis Social Bookmark Button
April
8
2008
1:27 am
Tags:
Post Meta :

Google just launched a new platform called App Engine.  Basically it allows you to run your web application on Google’s servers using much of their main infrastructure such as BigTable and GFS.  The best parts are that you write App Engine apps in Python and they include Django out of the box!  Mike Arrington has a video of Guido Van Rossum talking at the launch event as well as a pretty good summary at TechCrunch

It should be very interesting to see what this platform can do and how people will put it to use. 

AddThis Social Bookmark Button
January
27
2008
2:56 am
Tags:
Post Meta :

Recently I’ve been working on a web 2.0ish community site written in Django. As is frequently the case with such sites I often need to create lists or collections of psuedo-randomly selected items. For example on a user’s profile page there may be a box showing a few of the user’s friends, another box with some of the user’s
pictures, or a box with random comments the user has made.

Ideally in this type of situation I would simply preform a query with what ever rules I need and a random “order by” statement such as the following:

pictures = User.picture_set.filter(private=False).order_by('?')[:6]

Which generates SQL similar to:

SELECT * FROM `pictures`
WHERE private = 0 AND user_id = 5
ORDER BY rand()
LIMIT 6

In an ideal world this works great, I only get back as much data as I need and the site stays interesting because what the user sees is constantly changing/rotating. Unfortunately unless you are using MySQL or have less than a few hundred rows in the pictures table you are not in an ideal world. Under both MySQL 4 and 5 random ordering is horrifyingly inefficient. Adding that “ORDER BY rand()” can make a query that took a few milliseconds to run instead take tens of seconds. The problem gets even worse when you are working with a table containing millions of rows with thousands of rows which meet the given criteria. What is one to do?
(more…)

AddThis Social Bookmark Button
January
21
2008
12:31 am
Tags:
Post Meta :

Working on a project recently, I came across an interesting gotcha in using inline foreign keys in the Django admin.  Apparently the objects described by the inline fields are saved after the parent object is saved.  This becomes important if you try and do anything with the child objects as part of the parent object’s save functions.

(more…)

AddThis Social Bookmark Button
older »
Creative Commons License
All original content on this site is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.