February 24, 2006

Using Django to Supercharge Web Development

A nicely judged talk with pleasantly humorous diversions.

Django is intended to enable the creation of in-depth web sites such as washingtonpost.com, and Adrian Holovaty gave an example (lawrence.com) which certainly proved the point. He explained that another project had developed a web site to process reader feedback on the presidential debates ... in four hours! Since the roots of Django are in the newspaper world, they remind themselves that "the ink is never dry" on the web, and sites are subject to continual development.

After driving themselves stupid with PHP they discovered Python, fell in love, and set themselves the goals of:

1. Making web development stupidly fast
2. Automating the repetitive stuff
3. Practising loose coupling
4. Following best practices
5. Being efficient

An early (three-day!) project involved taking the local little league and building a web site featuring much of the same information available about major league teams. The kusports.com sites allows subscribers to sign up for baseball stats as short messages tot heir cellphones. Many other examples provided convincing evidence that Django is indeed versatile.

Last year (at PyCon 2005, when Djanfo was about 18 months old) Adrian gave a presentation on what was then "the CMS", and received a lot of feedback that suggested an open source distribution would be popular. Django is built around:

A URL dispatcher
A database wrapper
A template system
An admin framework, and
"Other pain relievers".

Django URLs are designed to be pleasant and readable. The scheme allows the programmer to write Python code that directly maps the URLs to program callables. This decouples the URL from the business logic. The callables, known as "views" in Django terminology, take a request object as their first argument (possibly with values extracted from the URL as additional arguments) and returns and HttpResponse object.

The usual development model is to design the database. Django helps you to create and populate the tables (though it doesn't stop you from using SQL if that turns out to be easier). The design process also results in the automatic generation of admin functionality that can be used imeediately by editorial staff to manage content. The Django team is fortunate to have a designer to build great interface pages.

The initial design is now production-ready, and the team can write the views and templates to produce the required pages. The templating language was deliberately kept simple (avoiding XML and programming languages) to maximize its utility to the designers.

The framework is fully ready for internationalization (the first add-on contributed to the project after it was open-sourced), and provides three different levels of caching: per-site, per-view and low-level (this latter being performed in raw Python).


Repeatedly-required view functionalities have been abstracted into "generic views" that are automatically available to developers with no further formality. Sites using Django include chicagocrime.org (an award-winning site that integrates with Google maps), washingtonpost.com (many feeds are provided by screen-scraping Python scripts), the Ellington system (an online publishing system for news and entertainment sites) and traincheck, a site you can SMS to find out when and where to catch your metro.

The 1.0 release is approaching, with much work upcoming in a post-Python sprint, and a book is expected later in the year from APress.

A nice final touch was the announcement of the availability of t-shirts featuring the slogan

I wish I were
powered by
Django

It was great to see enthusiastic and capable developers using Python for pragmatic purposes. Django does not attempt to be a fully-integrated content-management framework, but a loosely-coupled collection of components that work extremely effectively together to provide extremely efficient mechanisms for buildding database-driven web sites. Go to djangoproject.com and take a look!

4 comments:

Anonymous said...

Nice writeup! I'm always missing Adrian's presentations, so it's nice to read recaps.

One quibble: the shirts actually say "I wish I were powered by Django".

Steve said...

Thanks for the comment. I've amended the text (it's easier to trust you than stare at people's chests ... :-)

fs111 said...

@Wilson Miner:

You can watch a presentation of Adrian (+ the guy of RoR) here: http://www.djangoproject.com/snakesandrubies/

The sound isn't very good, but it is worth to take a look at.

André

Shoping Cart said...

Django supercharge your web application with strong tools available in the market. They develop large scale web applications for different corporations like Washington post.