Matt Gemmell

My new book CHANGER is out now!

An action-thriller novel — book 1 in the KESTREL series.

★★★★★ — Amazon

Django

development & tech 1 min read

I have a new job (as a Web Applications Developer) here in Edinburgh, about 5 mins walk from my flat. Most of the sites we make use Django, a web applications framework which uses Python as its implementation language, and I’m recommending you take a look at it.

A few of the features Django offers are:

  • Effective object-relational mapping (you can specify your model schema in Python, and it will automatically create both the necessary tables in your database and also an API you can use to manipulate your model).
  • Fast (lazy) model access (the dynamic API manipulates the queries, which are only then finally run when you access the results).
  • MVC paradigm, with hierarchical templating.
  • The whole "batteries included" philosophy of Python; i.e. what you want to do is probably already supported.
  • Pretty much zero-code generation of web admin interfaces to edit your sites and related objects; i.e. a CMS free with every site.
  • Cruft-free URLs; in fact, choosing pretty URLs is a central component to the Django workflow.
  • Comprehensive and always-up-to-date API reference free with every site (not just Django's own stuff; it also auto-documents your models and any added tags etc you've created yourself).

Even if you didn’t understand what the fuck I was talking about in a couple of those points, read on anyway, or go look at the actual documentation and tutorial. You’ll get it straight away, I guarantee it.

It will work fine with Dreamhost, and you can easily install it on your Mac to try it out (it has its own internal test server and works great with Tiger’s pre-installed version of Python, or you can run it via mod_python in Apache 2.x, or via FastCGI with Mac OS X’s default Apache 1.x). I installed and configured a copy on my PowerBook (using the internal test server) in about 5 minutes.

Django is by no means the only option out there, but from my exploration of it, it’s good technology. It’s even worth trying if you’ve never seriously coded in Python before (which was more or less true for me a few weeks ago). Hop on over to the site and read the introduction and the first 2 stages of the tutorial (even if you don’t install the framework) to get an idea of how it works. Its design philosophy and development methodology really speak to me, and in many places it’s loaded with the kind of elegance that appeals to me as a Cocoa developer. Seriously, set aside an hour to have a look.