Entries published in November 2006

5 entries published in this month. See also: all entries published in 2006, latest entries.

My site is smarter than I am

Looking through my stats today, I found an incoming link from a blog written entirely in Chinese. Now, I don’t read Chinese (I know about half a dozen words of Mandarin, but couldn’t begin to pronounce them with the right tones), so I ran it through Babelfish and found that this person was — apparently — commenting on how “comforting” my site was to him.

This left me somewhat befuddled, until I went back and looked at the comment he’d left here, and then at his screenshot of, sure enough, Chinese ...

Entry published November 22, 2006. Read full entry.

Django tips: get the most out of generic views

Recently at work I had the chance to revisit an application I’d written fairly early on in my tenure at World Online; I was still getting used to doing real Django development and to some of the quirks of our development environment, and ended up writing a lot more code than I needed to, so I was happy to be able to take a couple days and rewrite large chunks of the application to be more efficient and flexible.

The biggest win was more careful use of generic views, which this ...

Entry published November 16, 2006. Read full entry.

Comment problems

So it seems that something’s broken somewhere in all the hacks I do to the comment system, because every attempt to submit a comment is now met with AkismetError: missing required argument.

I’m working on it.

Update: commenting still won’t work, but apparently I’m not the only person running into this bug. I can’t find any notes regarding changes to the Akismet API, but that feels like the most obvious reason why this is suddenly happening.

Updated again: and just like that, things are working again. Judging from a couple other people ...

Entry published November 12, 2006. Read full entry.

Programming tips: learn optimization strategies

Recently I spent a little time talking about the tradeoffs between “concise” code and readable code in Python. Throughout that entry, I was using as an example a simple function which calculates numbers in the Fibonacci sequence; here’s one variation:

def fib(n):
    if n < 2:
        return n
    return fib(n-1) + fib(n-2)

The Fibonacci sequence is a classic example from introductory programming materials, because it teaches recursion, and recursion is an important core concept for productive programming. But it can also be useful for another educational topic ...

Entry published November 5, 2006. Read full entry.

Django tips: auto-populated fields

One of these days I’m going to run out of frequently-asked Django questions to answer. But today isn’t that day, so let’s look at one of the most common questions people ask: how do you set up a model with one or more fields that never show up in add/edit forms, and get automatically populated with some specific value?

A simple example

Let’s say you’re writing a to-do list application, and you want to have fields on the list model to store the date it was created and the time it ...

Entry published November 2, 2006. Read full entry.