Skip to content

Entries published on August 18, 2006

2 entries published on this date. See also: all entries published in August 2006, full archive.

I’m going to predict this now

Assuming they’re both still on TV in 2008, Jon Stewart and Stephen Colbert will both run for President. In different parties.

Entry published August 18, 2006. Read full entry.

Django tips: using properties on models and managers

While working on a little side project this week, I ran into a couple of very common use cases that often result in a lot of extra typing:

  1. Defining a BooleanField, or an IntegerField or CharField with choices which will, logically, break up instances of the model into certain groups which need to be accessed often.
  2. Repeatedly wanting to calculate a value based on the values of several fields of a model.

Let’s look at how to handle these common cases, while reducing the extra typing and making them behave in an extremely intuitive fashion.

The set-up

Consider as an example this model, which …

Entry published August 18, 2006. Read full entry.