Entries published in 2007

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

The why and wherefore

So, let me straighten a few things out.

First off, this is my personal blog. What you see here is me speaking my own personal mind, and I neither represent nor want to represent anything larger: not Django, not Python web development, not my employer, not anything except me and whatever I feel like writing about. This is an important point to keep in mind, because I don’t have any claim to represent anything else:

Entry published December 31, 2007. Read full entry.

The future of web standards

The world of standards-based web design and development has been undergoing something of a shake-up these past few days; Andy Clarke’s CSS Unworking Group” seems to have opened the floodgates to expressions of dissatisfaction with the current method of progress (or lack thereof) in developing and standardizing new features for web developers and designers. Alex Russell’s “The W3C Cannot Save Us” and my friend and former colleague Jeff Croft’s “Do we need a return to the browser wars?” continue the theme, as does Stuart Langridge’s “Reigniting the browser ...

Entry published December 17, 2007. Read full entry.

Speaking and writing

First off, if you’re going to PyCon (Chicago, March 14-16), make some room on your schedule; there are several interesting talks on Django scheduled, including one by yours truly.

The description of my talk on the PyCon site is somewhat pithy on account of space restrictions, but conveys the general idea of what I’ll be talking about; flexible, reusable Django applications are one of my pet topics, and I’ll be covering some techniques and best practices picked up from a couple years of real-world work with and on Django. It probably ...

Entry published December 12, 2007. Read full entry.

Requiring HTTP methods

Just a quick tip today: someone on IRC tonight was asking for an easy way to write a Django view which restricts itself to only allowing a specific HTTP method or methods. For example, a web-based API might want to only allow POST to specific views.

This is actually pretty easy to do with a set of decorators built in to Django, in the module django.views.decorators.http. Specifically, the fix for ticket #703 added three useful things to that module:

Entry published December 11, 2007. Read full entry.

A couple updates

Today marks two releases, both numbered 0.4, of django-registration and template_utils.

The new release of django-registration is largely a matter of policy; there’s no new functionality or features, but there is one backwards-incompatible change: the validation of passwords (verifying that the same password is entered in both fields) has been moved to the clean() method of RegistrationForm, which means that the error message from a password mismatch is now accessed via form.non_field_errors() instead of form.errors[‘password2’]. It’s a relatively easy change to make in your templates, but ...

Entry published December 9, 2007. Read full entry.

The magic of template tags

Over the last couple days I’ve spent some time discussing the word “magic” and exploring just what it really means, with an emphasis on the fact that a lot of “magic” in programming — though initially counterintuitive and not at all what you’d expect to have happen (and it’s precisely this reason which usualy makes “magic” a bad idea) — boils down to applications of fairly simple principles. As a real-world demonstration of that, yesterday we saw how to build a Python module object dynamically and make it work with ...

Entry published December 4, 2007. Read full entry.

Making magic

In yesterday’s article I spent a fair amount of time talking about the word “magic”, specifically in the context of Clarke’s Third Law, which states that

Any sufficiently advanced technology is indistinguishable from magic.

A big part of what I was getting at was that a lot of things which seem to be explicable only by appealing to “magic” are really just cases of technology — sometimes extremely simple technology — being used in a complex way. Or, to borrow an excellent turn of phrase from Terry Pratchett, “ninety percent of most ...

Entry published December 3, 2007. Read full entry.

Clarke’s Third Law

Every so often, a TV producer who wants to get ratings will air a “documentary” about some wonder of the ancient world. Say, the great pyramids at Giza. The formula for this “documentary” is pretty simple: you get a bunch of people from modern, industrialized nations to go crawl over these huge ancient monuments in Egypt and speculate on how those ancient Egyptians managed to build them. And, inevitably, a lot of these people will throw their hands up and decide that the Egyptians must have had help from aliens ...

Entry published December 3, 2007. Read full entry.

Where is Django’s blog application?

In terms of people looking for sample code or example applications to use/learn from, “where can I find a good Django-powered blogging application” is probably at the top of the frequently-asked questions list both on django-users and in the IRC; part of this is simply that, right now, there is no “definitive” Django blogging application; there are a bunch of them available if you go looking, but you’re not likely to get anyone to recommend one of them as “the” Django blogging app (unless the person doing the recommending ...

Entry published November 29, 2007. Read full entry.

Keeping up with the Django

Thanks to a couple big projects at work that I’m trying to finish up in time to devote my full weekend to the sprint, I don’t have anything directly code-related to throw out today. Fortunately, there are plenty of things people ask about Django which have nothing whatsoever to do with code, and I can deal with one of them today: how do you keep up with Django development?

Every so often, people pop up on the mailing lists, or on IRC, after doing an svn up of their Django tree ...

Entry published November 29, 2007. Read full entry.

Performance tips

Nearly two years ago, Jacob posted a round-up of useful tips for Django performance, geared mainly at the non-Django portions of your stack; suggestions like having dedicated media and database servers, memcached, plenty of RAM and database tuning really aren’t Django-specific. Two years later, all of his tips are still relevant and will still have an impact on the performance of your Django-based stack.

This leaves wide open the question of how to squeeze every last bit of performance out of Django — and your Django-based applications — though, so today ...

Entry published November 27, 2007. Read full entry.

Django sprint

I’ve got a couple articles brewing in the back of my head to finish out the month (and not a bad month, even with the unexpected break last weekend), but rather than write one of them tonight I’d like to pause and remind everyone that this Saturday — December 1 — is a major sprint day for Django. We’re hoping to make quite a bit of progress on some as-yet-unfinished features which need to land before Django 1.0 (the last sprint was an amazing leap forward, and it’d be ...

Entry published November 26, 2007. Read full entry.

Newforms, part 3

Now that I’ve got the user-profiles application out in the wild, let’s take a look at one last important feature of Django’s newforms library: the ability to dynamically generate forms “on the fly” from model classes, via the helper functions form_for_model and form_for_instance. And, just as importantly, let’s look at why they shouldn’t always be the first thing you reach for when you need to build a form.

How model-generated forms work

We’ve already taken a look at how to introspect Django models using Django’s own internal APIs, and if you’ve ...

Entry published November 25, 2007. Read full entry.

User profiles

Django, as you hopefully already know, provides a way to store additional information related to a User via the mechanism of setting up a site-specific user profile model, and supports this directly via the get_profile() method on every User object.

By way of supporting this, back in version 0.2 of django-registration I added the ability to specify a callback function which, upon creating a new User, could also create a default site-specific profile for that User; at the time it seemed like a good way to handle the common ...

Entry published November 24, 2007. Read full entry.

Newforms, part 2

Yesterday we took a look at how Django’s newforms library works and explored the different components, how they fit together and how the overall process of form validation takes place inside a newforms form. And while that’s all useful knowledge, it’s helpful to have some practical examples to see all of the various bits in action, so today we’ll look at a simple example which shows off some of the features, building it up step-by-step.

The specific example I’ll be using here is a user-registration form; about a year ago I ...

Entry published November 23, 2007. Read full entry.

Newforms, part 1

If you’ve ever had the pleasure (and I use that term somewhat loosely) of working with Django’s original form-processing system (which now lives in django.oldforms and is in the process of being deprecated), you’ll know that the replacement currently under development (which currently lives in django.newforms and will eventually become simply django.forms) represents an immense simplification and adds quite a few capabilities which weren’t present before. But because it’s still quite new (and parts of it are still being developed), it’s still not fully documented, and so ...

Entry published November 22, 2007. Read full entry.

Auth tips and tricks

Django’s bundled authentication framework is stupendously useful as an out-of-the-box solution for common user-authentication needs, and provides a ton of things basically for free: users, permissions, groups, login/logout functionality, middleware for automatically detecting the user’s identity, the ability to restrict views based on various attributes (including staff members, superusers, permissions and arbitrary tests), the list goes on and on. For probably 90% or more of the applications you’ll develop, the simple combination of the User model and the built-in login/logout views and middleware will take care of your ...

Entry published November 21, 2007. Read full entry.

Initial data and install-time code

A fairly frequently-asked question is something along the lines of “how do I provide some data which gets installed along with my application?”, or some variation on that, often including questions about how to ensure a particular bit of code is run when the application is installed via syncdb. Django provides several different ways of approaching this, depending on the exact situation and exactly what you need to do, and while they’re mostly documented it still seems to cause a lot of questions. So today let’s run down the ...

Entry published November 21, 2007. Read full entry.

Let’s talk about frameworks (again)

Over the past year or so I’ve written several articles on frameworks, mostly talking about the pros and cons of using them and specific design decisions pertaining to specific frameworks. For the most part this has been in the context of programming — specifically Python and JavaScript programming — because, well, I’m a programmer; this is what I do for a living. But every so often the general topic of frameworks for the Web, recently focused on frameworks for client-side technologies, rears its ugly head again and people have all ...

Entry published November 19, 2007. Read full entry.

My streak ends

First up, the bad news: my streak of one Django-related post per day in November is going to come to an end tomorrow. Some Thanksgiving plans (technically pre-Thanksgiving by a week, but nothing wrong with celebrating a little early) I’d had which were first on, then off, and are now on again, will be taking me out of town and probably offline from tomorrow morning through Sunday night. I toyed with the idea of putting together four entries and post-dating them to show up at the right times, but things ...

Entry published November 14, 2007. Read full entry.

Instant web sites

As much fun as it is to write about features of Django which aren’t that well documented, or which aren’t documented (_yet_; one of my goals with each sprint we do is to add to Django’s documentation and bring it closer to being truly comprehensive), there are a ton of features in Django that, while documented, don’t seem to get a lot of use. Which is a shame, because some of them are extremely powerful and make it almost trivial to accomplish otherwise-complex tasks.

So today let’s look at two of ...

Entry published November 13, 2007. Read full entry.

More on admin documentation

Since the last entry on admin documentation tricks seems to have been popular, and showed off a couple lesser-known things you can do, let’s take another look at the admin documentation system, and a couple more things you might not know about; in fact, until today I didn’t know about them, so if nothing else this entry will remind me that they exist and that I need to use them more.

Admin docs: a quick recap

In all Python programs, not just Django applications, you’re encouraged to provide documentation embedded directly in ...

Entry published November 12, 2007. Read full entry.

comment_utils 0.3

Since it’s Sunday and nobody’s reading right now, I’ll sneak in a release announcement instead of a pure “Django tip”: I’ve just released version 0.3 of comment_utils.

I’ve been running it for a little while, and it seems to be fine; if you run into any problems, please file a bug report.

Fixes and tweaks

Two big changes in this version are Unicode support and accommodations for a new method of template variable resolution.

As I wrote yesterday, Django’s Unicode merge means that anything which talks to external web-based APIs ...

Entry published November 11, 2007. Read full entry.

Unicode in the real world

Django’s Unicode branch merged back over the summer, but I imagine there are a lot of people who are still using pre-Unicode versions of Django and so haven’t started updating their code yet (it was several months before I had fully updated this site, for example). For the most part, updating to work with post-Unicode Django is pretty easy (and made even easier by Malcolm’s handy checklist), but there are still some things you’ll need to be careful about; one in particular is how to handle external APIs you ...

Entry published November 10, 2007. Read full entry.

Living without projects

The official Django tutorial walks you through the process of developing a Django application inside a Django project; in this view of the world, the “project” is seemingly the major focus, and the “application” just happens to be something you stuff inside it. For the purposes of learning and exploring Django — especially if you’re new to Python and unfamiliar with things like how to create your own modules and set up your Python path — this is a pretty good way to work, because it means that django-admin.py ...

Entry published November 9, 2007. Read full entry.

Moving into production

At some point, every Django-based project (hopefully) moves out of the development phase and into production deployment, and this can be a traumatic experience. As a result, there are a few things you’ll nearly always want to do during this process in order to transition smoothly and ensure you go to production with all your code humming along; this time around we’ll look at a few of the more common items, and if I miss out on something you’ve found useful, feel free to mention it in a comment.

General ...

Entry published November 8, 2007. Read full entry.

Documentation bookmarklets

Django’s admin application is capable of generating and displaying a variety of useful documentation (though once newforms-admin lands, that will be broken out into a separate documentation-only application), including lists of installed models and registered template tags, and a listing of valid URL patterns and the view functions they map to, along with the docstrings of those functions. But it also contains a page of bookmarklets — bits of JavaScript to be dragged into your browser’s bookmarks bar, and then clicked from various pages on your site — which enhance ...

Entry published November 7, 2007. Read full entry.

URLConf tips and tricks

I’ve written a couple of things recently talking about useful things to be aware of when you’re putting together the URL configuration for a Django application — one covering a pitfall you should watch out for with regular expressions and one touching on the utility of the “url” tag and the “permalink” decorator, and the “reverse” utility — but you can never have too much useful information about URL configuration, because for a lot of people it seems to be one of the trickier parts of Django. So let’s look ...

Entry published November 6, 2007. Read full entry.

Server startup” and its discontents

A fairly common question people ask on the Django mailing lists and in the IRC channel is “how do I have something run when the server starts up?” This is a somewhat tricky question to answer, because in many ways there’s no concept of “server start” in Django, and because the reasons behind the question vary from one use case to the next. So let’s take a look at just what people are wanting to do at “server start”, what that means (and, just as importantly, what it doesn’t ...

Entry published November 5, 2007. Read full entry.

Working with models, part 2

Now that we’ve got a handle on how to generically load models without necessarily knowing in advance which models, it’s time to start looking at interesting things we can do with them once we’ve got them. There are lots of uses for code which can introspect any model and extract information from it, some of which you’ve probably already seen:

Entry published November 4, 2007. Read full entry.

Working with models, part 1

In order to do all the things it does, Django has to contain quite a bit of generic code that’s capable of working with pretty much any model or combination of models you want to throw at it, and has to be able to introspect those models to get information about their fields, their relationships and other useful tidbits. There are also plenty of real-world use cases where your code needs to be able to do the same sorts of things, and so knowing how Django does it — and ...

Entry published November 3, 2007. Read full entry.

Handle choices the right way

A lot of common use cases involve a model field which needs to accept values from a restricted set of choices; for example, a field for selecting a US state should, logically, only allow values which correspond to actual US states. In Django’s ORM, this is represented by using the “choices” argument when defining the field, and generally this provides a fairly easy solution.

But it’s not always perfect: while string-based values (such as those for a US state field, which are — in Django’s implementation — simply two-letter postal abbreviations ...

Entry published November 2, 2007. Read full entry.

Django tips: template loading and rendering

I’ve been reminded today by Maura that November is National Blog Posting Month, when — in theory — bloggers the world over try to keep up a pace of one entry every day. I don’t know how well this is going to go, but I’d like to give it a try. And, inspired by Drew McLellan’s excellent 24 ways “advent calendars” of web-design tips, I’m going to give it a theme: one Django tip every day during the month of November. Kicking off the series, I’d like to focus today ...

Entry published November 1, 2007. Read full entry.

Be careful with your URL patterns

Tonight in the Django IRC channel, someone stumbled across a seemingly-odd error when trying to use a generic view:

TypeError: object_list() got multiple values for keyword argument 'queryset'

The problem turned out to be the URL pattern which was routing to the generic view. Consider a simple example, as might be found in a weblog application:

from django.conf.urls.defaults import *
from weblog.models import Entry

info_dict = {
    'queryset': Entry.objects.all()

urlpatterns = ('',
    (r'^(index|weblog)/$', 'django.views.generic.list_detail.object_list', info_dict)

The idea here is that either of two ...

Entry published October 14, 2007. Read full entry.

Another django-registration update

This one’s just a quick heads-up, but if you’re following django-registration you’ll want to take note: I’ve been doing a series of minor releases since 0.3, and it’s now up to 0.3p5.

There have been a few bugfixes since 0.3 that you’ll want, and also some important changes:

Entry published October 7, 2007. Read full entry.


My beloved Cubs went up against one of the best pitching teams in baseball, and forgot how to hit. Three games and they’re out, which is sad for me but good for you, because it means I can make unbiased predictions about the rest of the baseball postseason. So here goes.

NLDS: Rockies/Phillies

The Rockies are already up two games to none in a best-of-five series. As I write this Game 3 is scoreless in the third inning, but I expect this series to be over tonight or tomorrow; even ...

Entry published October 6, 2007. Read full entry.

iPod touch

When Steve Jobs announced the iPod touch at the beginning of the month, I knew I wanted one: it looked like the perfect little device for my assorted mobile needs. I spent a week or so thinking it over, then placed an order, and Friday morning as I was stepping out of the shower a FedEx delivery guy rang my doorbell to deliver it. I’ve spent the last couple of days playing with it, and so far I’m quite happy. What follows are my observations, which may or may not ...

Entry published September 30, 2007. Read full entry.

Standalone Django scripts

In the grand tradition of providing answers to frequently-asked questions from the django-users mailing list and the #django IRC channel, I’d like to tackle something that’s fast becoming the most frequently-asked question: how do you write standalone scripts which make use of Django components?

At first glance, this isn’t a terribly hard thing to do: Django’s just plain Python, and all of its components can — in theory — be imported and used just like any other Python modules. But the thing that trips most people up is the need, in ...

Entry published September 22, 2007. Read full entry.

django-registration update

For those of you who are using/following it, I’ve just pushed out django-registration 0.3. The basic workflow of the application is still the same:

  1. User signs up for account.
  2. User receives activation email.
  3. User clicks link in email to activate account.

But under the hood quite a few things have been rearranged to make the application cleaner and more extensible, and there have been a couple of backwards-incompatible changes for anyone using an older version. Here’s how it breaks down.

Backwards-incompatible changes

You’ll now need to create one extra template — registration/activation_email_subject.txt ...

Entry published September 19, 2007. Read full entry.

Django sprint wrap (for me)

I don’t know whether anyone else is going to continue on for the rest of the night, but I’m exhausted and I’ve got to be at work in the morning.

Today, for me, consisted of reading every open ticket in Trac and doing as much triage as I could; a lot of duplicates got closed, a lot of similar issues got consolidated, a lot of ancient tickets which have either been fixed or invalidated were marked as such.

Some highlights of the last 36 hours:

Entry published September 16, 2007. Read full entry.

Sprinting all the day long


So the “official” Django sprint day is over, though (in my time zone, at least) work actually started yesterday and looks like it’ll keep on going into tomorrow. Already the amount of activity (as measured by the Trac timeline) is simply astounding, and that’s likely to continue; there have been about 150 commits so far, and I couldn’t even begin to count the number of patches that have been filed and the number of tickets which have been triaged.

I got a bit of a late start today and focused ...

Entry published September 15, 2007. Read full entry.

Tips and tricks

In a few days it’ll be the weekend and I’ll (hopefully) have a bit of news regarding updates to the various applications I spun out during the process of rewriting all the code I’m using here, as well as the first official release of the blogging application I’ve developed (you can probably already find it if you know where to look, but for now it’s neither documented nor supported). In the meantime, there are a few minor and miscellaneous — but still useful — tricks I’ve started using which are ...

Entry published September 6, 2007. Read full entry.

ORM Wars

Last week while I was still on blog hiatus, Adam Gomaa wrote up a pretty constructive summary of why he prefers SQLAlchemy over the default Django ORM, and documented how he made SQLAlchemy a little less painful to use by writing a set of helper functions before moving on to announcing that he’s writing his own declarative layer — borrowing somewhat from Django’s model syntax — on top of SQLAlchemy.

I went back and read a few of Adam’s other posts, and generally I like what I see; he manages to ...

Entry published September 4, 2007. Read full entry.

Django, Accelerated

As of yesterday, this site is served from a Joyent Accelerator, running Django via Apache/mod_python backed by a PostgreSQL database. This setup probably isn’t for everybody, but if it’s right for you (and only you can make that call), here’s how I got everything running.

First things first

Make sure you’ve taken preliminary steps to secure your Accelerator before you do anything with it; this means things like setting up key-based SSH authentication and turning off password-based login, disabling SSH logins by root, etc.; the Joyent wiki has a “getting started ...

Entry published September 4, 2007. Read full entry.

Honey, I’m home

If you’re seeing this, congratulations: the DNS changes have propagated and you’re seeing this site, in all its redesigned glory, at its new home: a Joyent Accelerator.

This took quite a bit longer than I’d expected, largely because — while ostensibly working on redesigning the site and re-writing the blog application which powers it — I kept feeling the urge to spin off various bits of functionality into their own generic, standalone applications. Now I’m finally putting all that work to good use, and does it ever feel good.

Oh, and ...

Entry published September 3, 2007. Read full entry.

A quick survey

As you’ve hopefully noticed if you’re following things in the world of Django, the Unicode branch merged today, which means that Django is now safe for Unicode at every level (pending any bugs which need to be fixed). That’s great news for users of Django.

But it also means that developers of Django-based applications need to be aware of how Django handles Unicode and watch out for boundaries between Django and any bits of software which aren’t so enlightened.

Which is where you come in.

Over the past couple of months I’ve spun ...

Entry published July 5, 2007. Read full entry.

Hacking comments without hacking comments

Way back when I first set up this site, and threw together a minimal blog application to power it, I didn’t bother much with enhancing Django’s comment system. But later on, when I started getting a lot of comment spam (trivia: as of this moment, 15,153 comments have been posted here, and 14,406 of them — roughly 95% — have been spam) I realized I needed to do something, and quickly hacked Django’s comments application to add moderation.

At the time it seemed a reasonable thing to do ...

Entry published June 25, 2007. Read full entry.

Hypothetical framework choices

I subscribe to feeds of items tagged with “django” on a couple of sites, and tonight I noticed a link which posed a hypothetical situation of wanting to port a large J2EE application to either Rails or Django, and asking about making the choice between them.

I wrote up a reply, but attempts to post it there netted me “The page you were looking for was not found. Moron.” So here it is in all its glory; maybe someone will get some use out of it, maybe not.

Choose wisely

As ...

Entry published June 2, 2007. Read full entry.

django-registration update

I’ve just packaged up version 0.2 of django-registration; there are two big changes since the initial release which are worth mentioning (and which are, of course, covered in the documentation supplied with the download):

  1. The key_generated field was removed from the RegistrationProfile model, so you’ll want to drop the corresponding column in your database if you upgrade.
  2. A mechanism for automatically creating custom user profiles during signup was added; check the documentation for notes on how it works.

Also, a few bug fixes and minor enhancements went in; there’s a changelog in ...

Entry published May 29, 2007. Read full entry.

Software Update

Back when I first launched this site (about a year ago now), I mentioned that I’d someday release the blog application I’d written to power it. So far I’ve been held up by two large problems:

  1. The application itself was written using an SVN checkout of Django from April of last year, back when the codebase that became the Django 0.95 release was still known as “the magic-removal branch”.
  2. Some features (notably, a couple things I’ve done with comments) relied on hacking the source of Django itself.

So I’ve been on a ...

Entry published May 28, 2007. Read full entry.

A tale of two redesigns

Newsvine launched a redesign, or possibly a “realign”, today, adding a number of useful features while staying true to what has, overall, been an attractive and successful layout. Criticisms in the discussion thread are met with haiku and promises to work on it. Result: pats on the back all round.

Fark launched a total redesign today, and the number of design sins not committed is perhaps the easiest thing to enumerate:

  1. It doesn’t have any glossy Web-2.0 reflections.

And, well, that’s about it. Criticisms in the discussion thread are met with a ...

Entry published April 25, 2007. Read full entry.

Django template utilities

In the course of working on a couple personal projects (which will be released eventually), I found myself factoring out a lot of common code and making it more and more generic, until one day I realized I had a whole separate application just waiting to be documented and bundled.

So here it is: template_utils, a collection of generic and useful tags, filters and other tools related to Django templates. Full documentation is on the project wiki at Google Code, and distributed with the download.

Even though I’m using most of the ...

Entry published April 12, 2007. Read full entry.

Quote of the day

Jeff is on a mission to find view functions and template tags in our software which don’t have useful docstrings (and hence don’t have useful auto-generated documentation in the Django admin). The result (copied from IRC):

<jcroft> congratulations to ubernostrum: weblogs wins the award for the most well-documented Ellington app
<jcroft> which is especially impressive, given that it’s also the one with a fuck lot more views than any other

Jeff diplomatically declined to publicly shame the author of the worst-documented Ellington application…

Entry published April 10, 2007. Read full entry.

The types will save us!

So, that went over well. My goal was simply to point out that strong and static typing are not the same thing (and, correspondingly, that weak and dynamic typing are not the same thing), and somehow the comment thread got derailed into people trotting out exotic type systems and theoretical work to try to prove… well, I’m not sure exactly what they want to prove. But one big thing that seems to be causing trouble is this statement:

a common myth of some type systems is “if it passes type checks ...

Entry published April 1, 2007. Read full entry.

Reusable Django apps

A little while back I released a couple of Django apps to the world, and I’ve got a couple more in the pipeline (whenever some more of my copious free time rolls around, I’ll finish them up and get them out the door as well), so I’ve been thinking a bit about best practices for making them as easily reusable as possible. And James Tauber has started up a mailing list for discussing a Django application repository (anyone who’s interested in that should join up and get the discussion going ...

Entry published March 27, 2007. Read full entry.


One of the great holy wars in programming concerns itself with “type systems”, usually in the sense of “static typing” versus “dynamic typing”, and from time to time it flares up again. Unfortunately, most of the loudest voices are quite content to argue without really understanding the subject, and so proceed to build straw-man-style arguments based on what they think they know. Most often this seems to be a result of inexperience — far too many people have only ever worked seriously with one type of language, and so have ...

Entry published March 26, 2007. Read full entry.

Django snippets

Just in case you’re not subscribed to the Django mailing lists and/or aren’t at PyCon, today I launched a little side project I’ve been working on: djangosnippets.org, a site for Django users to share useful bits of code.

There are still a few things I’m working out (like feeds), but on the whole I’m pretty happy with it :)

Entry published February 25, 2007. Read full entry.

PyCon 2007: Web frameworks panel

(this was liveblogged during the panel, and the only later edits were to correct a couple of typos and add this notice — the content has not been changed)

Titus, the moderator, has welcomed everyone. No blood shed so far. Probably not taking audience questions.

Introduction of the panelists:

Titus pauses: “The most interesting thing about Django is, it’s what Guido would do.”

Titus says he’ll spark discussion by targeting Zope. First question: there’s a wide ...

Entry published February 23, 2007. Read full entry.

PyCon 2007: the prelude

So, I’m in Dallas, eagerly awaiting the beginning of the non-tutorial bits of PyCon 2007; I got here around 4:15PM (after a lovely flight where I was inadvertently bumped to first-class), and already things are rocking; I just got back from dinner and drinks with some folks who are doing really cool stuff with and to Django. Already got some interesting ideas and things to continue fleshing out, and I’ve got another four days to spend here.

If anyone’s looking for me, I’m lounging in my room in the Courtyard ...

Entry published February 22, 2007. Read full entry.

About model subclassing…

In Django 0.90 and 0.91 we offered the ability to subcless models, and a nasty hack called replaces_module which would let you tell Django to use a subclass in place of the original model it was inheriting from. The magic-removal changes broke that ability, and we’ve been slowly working toward getting it back (well, actually Malcolm has been rolling the Sysiphean rock up the hill and the rest of us have mostly been urging him on). I’d say it’s probably tied with automated database migrations as the feature ...

Entry published February 20, 2007. Read full entry.

Python framework design

Lately I’ve found myself being baited into the same old debate over and over and over again, and I’m getting tired of making the same arguments each time. Usually it begins with someone lamenting how Django is anti-community or too inflexible or generally suffering from a raging case of NIH. From there it progresses into people proclaiming how TurboGears or (more often) Pylons is objectively “better” because of how they’re designed, and how it would be nice for Django to follow their lead.

Before I go any further, I’d like you ...

Entry published February 19, 2007. Read full entry.

The JavaScript knowledge gap

JavaScript is a paradox of a language. It has nearly universal availability in its target market — client-side Web scripting — and is a major component of “Web 2.0”, but very few people actually write or even really know JavaScript. Many “modern” web-development frameworks remove the need for that by offering direct translation from some other language to JS, or by offering “helpers” which generate and include JavaScript automatically. And even among the few folks who don’t use those tools, most prefer to work entirely within the confines of ...

Entry published February 16, 2007. Read full entry.

A chronicle of the Ages of the Web

Sometime pretty soon (in fact, in the very next thing I write), I’m going to need some consistent way to refer to different periods in the history of the Web. I don’t know of any widely-accepted chronology for this, and I especially don’t know of any which really fits with the sort of references I’m going to need to make, so, with apologies to J.R.R. Tolkien, I present my own chronicle, derived from one too many nights of having re-read The Lord of the Rings when I should ...

Entry published January 24, 2007. Read full entry.

Choosing a JavaScript library

Previously we looked at some objections to JavaScript libraries and some possible responses. Now it’s time to ask a bigger question: do you need a JavaScript library, and if so how should you go about choosing one? I’m not going to recommend any particular library, because I don’t think there’s such a thing as one-size-fits-all in web development, but I can list a few things which are useful to keep in mind when making these decisions. So let’s dive in.

Do you need a library?

No matter what language you’re writing, libraries ...

Entry published January 22, 2007. Read full entry.

Let’s talk about JavaScript libraries

JavaScript’s got a bad rap; it’s the language everybody loves to hate, and the one language which, more than any other in the modern web developer’s toolbox, people will go to insane lengths to avoid writing directly (witness Google Web Toolkit, JavaScript “helpers” in server-side frameworks, etc.). Which isn’t fair, really, because (as I’ve said many a time) most people don’t actually hate JavaScript the language; they hate the buggy and inconsistent implementations of JavaScript in major web browsers and, to a larger extent, the buggy and inconsistent implementations of ...

Entry published January 15, 2007. Read full entry.

Be liberal in your HTTP Accept…

Ever since I started using Joe Gregorio’s mimeparse module to help with my OpenID delegation, I’ve been treated to a first-hand tour of the various things people have thought it would be good to stuff into the HTTP Accept headers their applications send. So, naturally, I’m going to start a gallery of some of my favorites.

So far the winner in the “is that really what you meant” category is what appears to be the default header sent by Java’s HTTP connection classes:

text/html, image/gif, image/jpeg, *; q=.2, */*; q ...

Entry published January 12, 2007. Read full entry.

OpenID delegation under Django and lighttpd

There’s been lots and lots and lots of buzz around OpenID in the last couple weeks, which makes me happy because OpenID is a pretty darned cool system. Simon is doing all sorts of cool things, and Sam Ruby wrote up wonderful step-by-step instructions for OpenID delegation, which lets you use your own domain name to sign in with OpenID even if your OpenID is hosted somewhere else.

I sat down tonight and worked out how to set it up here, because that’s a nifty and useful trick; Sam’s Apache rewrite ...

Entry published January 8, 2007. Read full entry.