Entries published in 2008

46 entries published in this year. See also: latest entries.

Users and the admin

So, for as long as I can remember the single most-frequently-asked question about the Django admin has been some variation of “how do I set a foreign key to User to automatically be filled in with request.user?” And for a while the answer was that you couldn’t do that, really; it was and still is easy to do with a custom form in your own view, but up until a few months back it wasn’t really something you could do in the admin. Now, as of the merge ...

Entry published December 24, 2008. Read full entry.

Why I like pip

So yesterday I explained some of the reasons why I don’t like setuptools. In essence, my objections boil down to one idea: application packaging and application development should be orthogonal concerns. The way setuptools works, however, seems to tend, inevitably, toward coupling them to each other. I gave one example — the way the default behavior of installing zipped packages (an ironic twist: the man who so eloquently explained how Python is not Java has spent so much time and effort trying to implement Java packaging conventions in Python) leads ...

Entry published December 15, 2008. Read full entry.

On packaging

So currently there’s a bit of a to-do involving Debian’s Ruby packaging team and the Ruby “gem” system. This document does a good job of summarizing the issues from Debian’s perspective. And of course, the Ruby side of it is no less heated; an example is here.

A lot of this is the usual back-and-forth between (on the one side) application developers working in one particular language, who want to distribute their applications to the widest possible audience and so use an operating-system-agnostic but language-specific tool for doing so, and ...

Entry published December 14, 2008. Read full entry.

Let’s talk about Python 3.0

There’s an old joke, so old that I don’t even know for certain where it originated, that’s often used to explain why big corporations do things the way they do. It involves some monkeys, a cage, a banana and a fire hose.

You build a nice big room-sized cage, and in one end of it you put five monkeys. In the other end you put the banana. Then you stand by with the fire hose. Sooner or later one of the monkeys is going to go after the banana, and when ...

Entry published December 5, 2008. Read full entry.

Generic inlines and Django history

The other day at work I stumbled across my first opportunity to use a relatively-new feature in the Django admin, one which turned what had looked like it would be a fairly nasty task into, basically, a five-minute job (plus staging, testing and deployment, of course, but that happens no matter how long it takes to develop the code). I’ll get to the specifics in a minute, but first I want to give a little bit of background on what, exactly, I was working on, since it’s sort of a ...

Entry published December 4, 2008. Read full entry.

Another take on content negotiation

Today my co-worker Daniel posted a class which performs content negotiation for Django views, allowing you to write a single view which returns any of several types of responses (e.g., HTML, JSON, XML) according to the incoming HTTP Accept header. While it’s certainly cool, he notes a couple of issues with it (including the redundancy it introduces in URL configuration).

So let’s see if we can’t come up with a way to work around this.

Holiday decorations

It seems that the best way to approach this is to avoid the need ...

Entry published November 29, 2008. Read full entry.

Writing custom management commands

The other night in the #django-dev IRC channel, Russ, Eric and I were talking about custom management commands for certain types of common but tedious tasks; Eric was discussing the possibility of a command for automatically generating a tests module in a Django application, since he’s our resident unit-testing freak, and I started toying with the idea of one to generate basic admin declarations for the models in an application.

So I sat down and spent a few minutes writing the code. I haven’t decided yet whether I want to clean ...

Entry published November 14, 2008. Read full entry.

So you want a dynamic form

So I havent really been doing much writing lately. That’s mostly a consequence of the fact that:

  1. Django 1.0 was released, and meeting the schedule for that took up an enormous amount of time.
  2. After that, there was DjangoCon.
  3. Oh, and there are all sorts of things in my life, including a book, a gigantic codebase and dozens of sites, which all need to be updated. Our entire team here in Lawrence has been running short on sleep for a good long while now.

Anyway, I’m going to force myself to break out ...

Entry published November 9, 2008. Read full entry.

What’s next?

What happened today:

Each State shall appoint, in such Manner as the Legislature thereof may direct, a Number of Electors, equal to the whole Number of Senators and Representatives to which the State may be entitled in the Congress: but no Senator or Representative, or Person holding an Office of Trust or Profit under the United States, shall be appointed an Elector.

What happens next:

The Electors shall meet in their respective states, and vote by ballot for President and Vice-President, one of whom, at least, shall not be an inhabitant of the ...

Entry published November 5, 2008. Read full entry.


I’m sitting here in Building 40 at Google, waiting for this morning’s first DjangoCon keynote to start, and getting ready for the Django technical design panel which comes immediately afterward. Naturally, I’m taking advantage of the down time (and Google’s bandwidth) to upload my slides from yesterday’s talk. If you’ve seen/read the slides from the version of this talk I gave at PyCon, I can tell you that there are now 40% more slides and they’re all new material.

And, of course, the whole deck of slides is CC-licensed ...

Entry published September 7, 2008. Read full entry.

Database heresies

While scanning reddit, I saw an article pop up by Jeff Davis lamenting the way most people interact with databases, particularly when it comes to ORMs. Jeff seems to be pointing out (and, to an extent, conflating) two issues:

  1. At the moment, programming languages and SQL don’t really mesh all that well.
  2. Most people, in Jeff’s opinion, take the wrong approach to working with a database from their programming language of choice.

The first point is one I’m happy to concede; SQL is a fundamentally different beast from, well, pretty much any ...

Entry published August 4, 2008. Read full entry.

Let’s talk about DVCS

So, a few years ago all the cool kids were switching from CVS to Subversion. These days, all the cool kids are switching from Subversion to some form of distributed version control; git and Mercurial seem to be the ones with the largest market shares. This switch is being accompanied by a simply deafening amount of hype about DVCS and how it’s a revolutionary new paradigm and will completely change the way people work and… well, the usual stuff.

Over the past few months I’ve tried out both of the popular ...

Entry published July 28, 2008. Read full entry.

Microformats and such

I hope you’ll forgive this brief diversion from my ongoing attempt to distinguish web developers from web designers, but it’s late, I’ve had a couple beers and I’ve been tinkering a bit with some code. Regularly-scheduled programming will return shortly.

So. The microformats people and the accessibility people are at war with each other, or so it seems (remember to read that article with tongue firmly in cheek). The cause of this tempest in a teapot is a simple enough question: how do you embed both a “human friendly” and “machine ...

Entry published June 29, 2008. Read full entry.

Designers and developers: FIGHT!

In a thorough and well-thought-out article published on Tuesday, Andy Rutledge listed what he considers to be the essential skills and knowledge for a web designer; this list is notable not only for what it includes — namely, a masterful distillation of just what it is that a web designer should be able to do — but also for what it explicitly excludes:

Note also that nowhere in this list do the words “Photoshop,” “Illustrator,” “Dreamweaver,” or “Fireworks” appear. As I and others have observed plenty of times ...

Entry published June 26, 2008. Read full entry.

Media and performance

Ever since last September when I moved this site off the shared-hosting account which had been handling it from its initial launch, I’ve been using separate services to handle static files — “media” in common Django parlance — instead of using the same web server instance, or a separate instance running on the same physical server as the rest of the site. Specifically, I’m using Amazon S3.

When I first explained this a few months ago, I got a bit of pushback and a few questions, both in comments and ...

Entry published June 23, 2008. Read full entry.

Things I have learned about XHTML

The following are gleaned from the comments to my recent explanation of why I chose to use HTML 4.01 Strict for my redesign, rather than a flavor of XHTML, an explanation in which I mostly boiled the debate — for my needs, here on this site — down to “XHTML doesn’t offer me any compelling advantage, and it’s more complex to do right than most people know/admit”.

Advance warning: yes, this is snarky and is going to make fun of uninformed comments. Yes, I do think it’s necessary ...

Entry published June 21, 2008. Read full entry.

Let’s talk about documentation

One of the most active threads on reddit’s programming section right now discusses things people look for when reviewing someone else’s code; the article being discussed treats this as a great interview question and points to things like algorithm choices and object-oriented design as good responses. While these are important considerations, I’ve found I tend to make snap judgments long before I get to that level of analysis, and they’re almost always based on one key factor: documentation.

Of course, I have the luxury of mostly reviewing Python code, and ...

Entry published June 21, 2008. Read full entry.

Fun with queryset-refactor

Mixed in with my recent redesign and server move, I’ve taken the opportunity to update the Django trunk snapshot this site runs on; generally I snapshot a week or two after a big change, once I’ve had time to see any major bugs shake out and update the various applications I use. This time around the recent big change was the queryset-refactor branch landing in trunk. Most people have been focusing obsessively on one single feature QSRF reintroduced, but that’s a bit of a shame because it brought tons of ...

Entry published June 19, 2008. Read full entry.


So, as I let the dust settle from the most controversial changes I made in the redesign (and tweak some things and watch my stats in response to the constructive feedback I’ve gotten), I’d like to address the other big change that people have been asking about: why I switched (switched back, actually) from XHTML 1.0 to HTML 4.01.

The short and sweet reason is simply this: XHTML offers no compelling advantage — to me — over HTML, but even if it did it would also offer increased ...

Entry published June 18, 2008. Read full entry.


Back in March when I read about Ryan Tomayko’s redesign, I had two immediate reactions:

  1. Wow, that’s hardcore!
  2. I should try that myself sometime.

Of course, at the time I was busy working on a book and so couldn’t really spare much effort for doing redesign work. Once that was in its final stages, though, I sat down and started thinking about what I could do to reduce the amount of cruft hanging around my weblog. Many revisions later, I have something I’m close to being happy with; of course, I don’t think ...

Entry published June 15, 2008. Read full entry.


Following up on last weekend’s housekeeping announcement: hopefully you’re noticing that things look a little different around here. There’s a lot going on, and a lot to write about (expect that in coming days), but in summary:

  1. A nice, fresh look for the site. My focus this time around was on minimalism and clean design, emphasizing content as much as possible. See Ryan Tomayko’s recent redesign work for my inspiration.
  2. Upgrades and improvements to most of the applications I’m using. These will find their way into proper releases eventually, but for now ...

Entry published June 13, 2008. Read full entry.

Kick me

On a recent plane ride, I was watching an episode of The West Wing which had flashbacks to the original campaign which set up the Presidency on which the show is based. There’s a scene in that episode where Abbey Bartlet — the eventual First Lady on the show — is talking to some of her husband’s campaign staffers about whether her husband is ready to really run the campaign and be President. The dialogue is classic:

JOSH: Well, is he going to be ready?
ABBEY: You bet your ass he ...

Entry published June 7, 2008. Read full entry.

Housekeeping notice

A minor heads-up: going to be doing a little maintenance this weekend, which means that this site will be seeing some downtime as I upgrade a few things. I’ll most likely just turn things off for a bit while that’s running, but you may occasionally see an error page if I forget or if I manage to screw up.

Everything should be back to normal by Monday.

Entry published June 7, 2008. Read full entry.

django-registration 0.5

Just a quick note: I’ve bumped django-registration to version 0.5. New in this version are Italian and Serbian translations, registration at the Cheese Shop (so you can now do easy_install django-registration) and a few bugfixes.

Notes you might care about:

Also: I’m considering taking my ...

Entry published June 5, 2008. Read full entry.

Book notes

A few notes about the book:

Entry published June 3, 2008. Read full entry.

And that’s a wrap.

I just finished reviewing and annotating the index for the book, and sent it back. And with that, I believe it’s finally done; soon it’ll be in the hands of the printer, and sometime hopefully next month you’ll be able to visit your local bookstore and pick up a copy.

My immediate plans include flying back east tomorrow to watch a couple of dear friends get married, and hopefully spending the next few days without interacting with any computers in any way.

After that… I’ve got a lot of things to write ...

Entry published May 28, 2008. Read full entry.


As a general rule, the things I write fall into two categories: long-form (for the medium of blogging, that is; the book is “long” in a very different sense), in-depth pieces which tend to be either tutorials on various aspects of working with Django or op-ed bits on web development and the Web in general, and short-form tidbits which mostly consist of a thought or two. Typically I never post the latter, because it always feels like a waste: if I could give it a more thorough treatment, I’ll hold ...

Entry published April 29, 2008. Read full entry.

Minty fresh

For a while now I’ve been really disappointed with the state of web stats.

When I moved over to my shiny new server back in September of last year, I ditched Mint because it requires PHP and MySQL, neither of which will ever, under any circumstances, be allowed on my box. So I started fishing around for something else; most other host-it-yourself stats packages were, frankly, crap either in terms of what they tracked or the interface they presented it in, which led me to look for a hosted solution.

I tried ...

Entry published April 19, 2008. Read full entry.

I don’t normally do memes

But this one was geeky and interesting enough to be worth it:

$ history|awk '{a[$2]++} END{for(i in a){printf "%5d\t%s\n",a[i],i}}'|sort -rn|head
   75   cd
   64   ls
   34   ssh
   29   python
   21   rm
   21   hg
   20   svn
   18   man
   18   less
   17   screen

Entry published April 10, 2008. Read full entry.

Batteries sold separately

At first glance, Google’s App Engine looks like a great way to build the next big web application; you get access to a massively scalable infrastructure, you get access to a huge existing authentication system, you get baked-in stats, you get all sorts of cool goodies.

Oh, and you get Python, which is a great language for writing web applications, and I’d be remiss if I didn’t take some pleasure in Django being available out of the box.

Personally I don’t really care one way or another about hosting code with Google ...

Entry published April 8, 2008. Read full entry.

More slides

I gave a quick talk at the Django open session last night, and I’ll be giving it again here in a few minutes as a proper lightning talk, briefly walking through the process of some of the database-backed journalism projects we do at the Journal-World (specifically this feature on crime reports at the local university campus).

Slides are already online. If you’re at PyCon and want to hear the talk, come to the ballroom.

Entry published March 16, 2008. Read full entry.


I just finished my talk, which apparently included a bonus live transcript on IRC by Justin Lilly, and I think it went pretty well considering how much ground it had to cover and how nervous I was up until the moment when I started talking.

If you aren’t at PyCon, or if you are but didn’t come to the talk, or if you just want to download them and mash them up, my slides are online:

Since it includes several CC-licensed photos, and since I’m a fan of open ...

Entry published March 15, 2008. Read full entry.

Where to find me at PyCon

My flight arrived in Chicago a while ago, and despite an attempt by the hotel to screw it up, I’m currently sitting in my room enjoying a beer before bed. Here’s my plan for the next few days:

Outside of these predictable time slots, I’ll probably be all over the place; I haven’t yet made up my mind ...

Entry published March 12, 2008. Read full entry.

Advertising and me

Recently I received an email from a company that’s in the online advertising business; they run a network that places targeted ads on a collection of sites, and wanted to know if I’d be interested in running them here. I just finished writing a reply and, since I’ve gotten a couple such offers in the recent past, I figured it’s probably time to make a public statement of my policy toward ads on sites that I personally manage. It’s very simple:

I don’t run ads, and don’t plan to.

I don’t personally ...

Entry published March 11, 2008. Read full entry.

Victory for the web

Standards” means “standards”. Thank you for listening.

Now. Anybody out there who’s relying on version-specific quirks, get off your ass and fix your sites. It’s 2008, for crying out loud.

Entry published March 3, 2008. Read full entry.


Once upon a time, I was doing a server setup at work, installing all the various prerequisites and utilities to support the things we use. One part of that involves installing Jing, which we use for XML validation; Jing is written in Java, and so we use gcj (the GNU Java compiler) to compile it for use, ending up with a nice little binary we can call from anywhere.

Now, we’ve standardized on Ubuntu for our servers, so installing gcj should be as simple as apt-get install gcj (or, more often ...

Entry published March 3, 2008. Read full entry.

Managers versus class methods

In the triumphant return of “James answers questions from the django-users list”, today I’d like to take a few moments to talk something that’s recently become something of a hot topic, spawning not one but two threads, as well as a couple off-list email discussions: what, exactly, is appropriate to put into a method on a custom manager as opposed to, say, a class method, and when and how can you tell?

This is a somewhat tricky question to answer, since there’s a substantial grey area where personal preference will be ...

Entry published February 25, 2008. Read full entry.


Once again, with apologies to John Gruber…

Q: Do standards-based developers have to use X-UA-Compatible if they care about progressive enhancement for future browsers?

A: As I see it, yes.

Q: Doesn’t Internet Explorer already offer a fine-grained way to target specific versions?

A: Yes, definitely.

Q: So if there was a problem with the IE6 to IE7 transition, doesn’t that mean people weren’t properly using an existing tool which could have future-proofed their sites?

A: You may rely on it.

Q: Given that, is it likely that people will properly use a new ...

Entry published February 19, 2008. Read full entry.


It’s sad to reach the point where “epic fail” is the most apt term I can come up with to describe an article by Zeldman, but that’s where I am today. His article “Version Targeting: Threat or Menace?” in today’s ALA is so far off the mark that, honestly, I can’t come up with any other description.

No, Microsoft is not relevant anymore.

No, the default behavior is not correct.

No, the switch does not solve the problems the IE team claims to be fighting.

No, it is not and ...

Entry published February 19, 2008. Read full entry.

On “conceptual integrity”

Mark Ramm has a nice post this morning talking about Adam Gomaa’s discussion of “conceptual integrity” in Python web frameworks; I think it’s worth a read.

The key point Mark touches on is good documentation: ensuring that people see and understand the overarching structure of the framework is, ultimately, the key to helping people understand how it can help them get their work done. In the case of Django there is an official “overview” document, but it’s really not as good as it could be; it’s basically a whirlwind tour of ...

Entry published February 11, 2008. Read full entry.


Between normal work, working on the book, working on my upcoming PyCon talk and working on a couple little things on the side, I haven’t had much time for blogging lately, especially about Django. But I’ve built up a collection of little things that need to get posted, so I’m just going to start dumping them out here and then get back to not having any free time :)

A django-registration update

I’ve bumped django-registration up to version 0.4p2; the new package doesn’t add any new features, but it does ...

Entry published February 10, 2008. Read full entry.

Media moves

As of sometime this weekend when the DNS change propagated, all static/media files for this site migrated over to Amazon’s S3 storage service; when I relaunched back in September, media was coming off a Joyent BingoDisk account. While a change in media serving technology really isn’t all that sexy or exciting compared to some aspects of web development (or as popular as writing about whatever Microsoft is doing today), I’d like to take a moment to talk about this move, why I decided to go with S3, and point ...

Entry published February 7, 2008. Read full entry.


Last week I spent some time dissecting what, I believe, is the reason behind the announcement that Windows Internet Explorer (née “Microsoft Internet Explorer”) will, as of version 8, include the ability to emulate previous versions of its rendering engine and, in addition, will default to emulating IE 7 when no version is specified (with the exception of HTML 5, which reputedly will trigger a genuine “standards mode” in IE 8).

At the time, I was only concerned with analyzing why Microsoft has chosen this route; I was mostly thinking ...

Entry published January 28, 2008. Read full entry.


For centuries Galactic civilization has stagnated and declined, though only a few ever realized that. But now, at last, the Periphery is breaking away and the political unity of the Empire is shattered. Somewhere in the fifty years just past is where the historians of the future will place an arbitrary line and say: “This marks the Fall of the Galactic Empire.”

— Isaac Asimov, Foundation

Amid clamor in the world of finance, the world of Web technology today is experiencing its own crash, of a sort. The unexpected announcement ...

Entry published January 23, 2008. Read full entry.

Shared hosting is not a ghetto

In the wake of the Dreamhost blog’s post on Rails and shared hosting, there’s been a bit of a meme going around with respect to deploying frameworks like Rails (or Django, or TurboGears…), and which more or less consists of people asking why, if you’re using one of these frameworks, you’re not just ponying up for a VPS or dedicated server. After all, it’s not like the offerings these days are that much more expensive than commodity shared hosting.

There are some problems with this attitude, some of which are elegantly ...

Entry published January 13, 2008. Read full entry.

Web frameworks and web hosts

Today John Gruber linked to a post on the official Dreamhost blog lamenting the state of web-framework deployment on consumer-level shared hosting; while the post itself is largely concerned with Ruby on Rails, the current state of deploying popular (non-PHP-based) web frameworks on hosts like Dreamhost is, well, abysmal. A search for “dreamhost” in the archives of the django-users mailing list turns up nearly five hundred results, many of them people struggling to get Django working, and I imagine that similar searches of list archives for other frameworks ...

Entry published January 10, 2008. Read full entry.