Simon Willison’s Weblog

Introducing Django

You may know that I spent a year working in Kansas for a local newspaper—the Lawrence Journal-World. I’m delighted to announce that a decent chunk of the software I worked on there is now available as open-source, in the form of the Django web framework.

Django is an MVC Python web development framework with a strong emphasis on content management. While comparisons with Rails are inevitable (I plan to post one myself shortly), it should be emphasized that Django is by no means a clone of Rails—in fact, development on Django started in October 2003, months before the first public Rails release. That the two frameworks share so many ideas is, I feel, a testament to the design of both.

Django was initially developed by Adrian Holovaty and myself, with Jacob Kaplan-Moss joining the team shortly before my departure. The framework evolved during the construction of a number of sites, which included:

  • 6newslawrence.com, local TV news, the first site to launch using the then nascent Django framework.
  • lawrence.com, a local entertainment site. Every town should have a site like this; sadly, very few do.
  • VisitLawrence.com, a local tourism site.
  • KUSports.com, a sports news site covering the University of Kansas.
  • LJWorld.com, a local news site and the flagship for the Journal-World.

It’s also purring along under the hood of chicagocrime.org and the Django project site itself.

Adrian and I developed Django to allow us to create reasonably complex database driven web applications in as little time as possible. A local newspaper produces a huge amount of information—news stories, events listings, obituaries, sports results, marriage announcements, photo galleries, polls, weather reports and dozens of other bits and pieces. To maximise their value and potential for reuse, these things need to be stored in a database. That database needs a user interface for people to add and modify content, and of course the information needs to be published to a website somewhere.

Django automates most of this—and makes the rest as easy as possible. You create a data description (kind of like an SQL table schema but with additional information about validation rules and interface widgets) and load it in to Django. Django then creates the database tables, model classes and a comprehensive web-based administration interface for your site’s staff. All that’s left for you to do manually is the code for the public site, which is generally a case of writing a few lines of controller code, configuring some URLs and knocking out some templates.

To give you an idea of how much this speeds up the creation of new sites, consider the case of Game. Game was a site created to provide detailed coverage of little-league games in and around Lawrence (for non-Americans, little-league is baseball and softball for children aged around 5 to 11—it’s amazingly popular). The entire Game site, including news, fixtures, match results, team profiles and even weather forecasts for forthcoming matches took two days to develop.

I haven’t been involved with Django since leaving the Journal-World back in September, but now that the framework is open-sourced I look forward to contributing to its further development—both in terms of documentation and actual code. There’s already plenty to look at on the Django site (designed by the ever-talented Wilson Miner); I suggest the overview as your first port of call.

Expect to hear a lot more about the framework in the next few weeks.

This is Introducing Django by Simon Willison, posted on 17th July 2005.

Tagged ,

Next: Understanding the Greasemonkey vulnerability

Previous: Less code is more

Previously hosted at http://simon.incutio.com/archive/2005/07/17/django