I think everyone who has worked with me has heard about my love for, and extensive use of, the Django framework for the Python language. Before I came across Django, “the web framework for perfectionists with deadlines”, I thought making websites was far too tedious and frustrating to make a career of it! The tools I had used and seen used to build websites were simply not as powerful as the computing tools being developed to support other areas of creative design. Here are some reasons that Django changed my mind.
Django and creativity support
In 2005, pretty much everyone who is anyone in creativity support tools research attended a workshop on Creativity Support Tools, and produced this report summarising the state of the art. There are a few chapters on how to design and evaluate creativity support tools. For demonstrating Django’s creativity support ability, I’ll use the list in “Design Principles for Tools to Support Creative Thinking”, written by Mitch Resnick, Brad Myers, Kumiyo Nakakoji, Ben Shneiderman, Randy Pausch, Ted Selker and Mike Eisenberg.
A few items in Resnick et al.’s list apply to the concept of (open-source) web development tools in general:
-
invent things you would enjoy using yourself
-
support open interchange
-
balance user suggestions with observation
-
iterate your development
-
design for designers
-
evaluate your tools
However, in the other parts of the list, Django stands head and shoulders above other tools (in particular compared to CMSes like Drupal, Joomla and Wordpress, but also compared to writing raw PHP+MySQL):
-
Provide a low threshold, high ceiling and wide walls. This means it is easy for novices to get started, but that the tools are sophisticated, and suggest a wide range of explorations. I’d say that the trickiest thing about Django is getting started in it, since you need to know how to program, and it is so bare-bones out of the box. But after you’ve followed the tutorials, and ideally worked on someone else’s Django site, you’ll be up to speed in no time. As for high ceiling and wide walls, it’s pretty great. It’s all the power of Python if you need it; it’s well-architected and well-documented, so you can override parts of its functionality if necessary. There is some discussion over whether it’s up to the task of running the world’s few mega-sites, like Flickr and Wikipedia, but the fact that Google has adopted Django for its App Engine is very encouraging.
-
Support exploration. Like most worthwhile languages, Python has a fully-featured debugger. However, it also has an interactive shell (which Java, for example, lacks), dynamic data types, late binding, strong introspection and rich libraries, all of which make it great for testing out ideas where the action happens, even debugging right there in the browser. Further, Django is quick not only because Python is quick, but also because HTML and SQL are slow1. Django neatly seperates them out, so that the HTML can be done by someone else (suckerzzzz!) and the database headscratching is handled in a pythonic way (no JOIN directives!).
-
Support many paths and many styles. Django maintains a zenlike agnosticism about what it plugs into. For example, it supports MySQL, PostgreSQL, SQLite and Oracle databases out of the box, but if you were inclined to write a database mapping for another database, it should work seamlessly. Similarly, there is a built-in template language, which takes python variables and renders them into HTML, but you are free to replace it with your own.
-
Support collaboration. This separation of concerns means that there is very little programming code in the HTML templates, unlike the distressingly common PHP pattern of mingling HTML and PHP code. This means that someone else can work on the look and feel, safe in the knowledge that they won’t ruin your back-end logic.
-
As simple as possible. It is easy to sell a product which contains ‘more features’, and gatekeeper ‘experts’ are used to using complex tools, say Resnick et al. However, reducing the number of features can actually improve the user experience, and that’s the case with Django. Think of it as a system for building Content Management Systems, a Content Management Metasystem, if you will. Most CMSs are quite fully-featured, with everything that 80% of people want to do shoehorned in. The problem comes when you want to turn all that stuff off, to improve your users’ experience, and to fit the architecture inside your head. Modifying things with fully-featured CMSs can be a bit of a nightmare — you can hack the codebase, but then a new version comes out, and you have to replicate the hacks in the new version. Or you can write a plugin that works around it, but that’s a lot harder. Django pulls off the incredible trick of being feature-rich, but doing absolutely nothing that you didn’t tell it to. This is why there is no blogging application for Django – if you need something that Wordpress won’t do, then it’s probably going to be better to make your own.
-
Choose black boxes carefully. The choice of the ‘primitive elements’ of a tool is extremely important, because they determine what ideas the creative user can explore with that tool. Django is open-source, and written in Python, the same language that you use to write Django apps. Therefore, if you need to, you can modify Django’s source code in the same way that you modify your own.
What does all this mean? Well, given how supportive Django is of creativity, it follows that web developers who use Django for their sites can be more creative than those who do not. That is not to say that if you don’t use Django then you are uncreative or unimaginative; it’s just that you have less time and freedom to be creative, because you are limited by your tools, and spend more resources reinventing the wheel, hunting down bugs, unravelling PHP and HTML bolognese, turning off features you don’t need, and so on.
A corollary: Django sites can be more usable. As an interaction designer, you learn that the tried-and-tested way to build a usable system is, literally, to try and test. In other words, you build protoypes of websites and put them in front of people to see what needs fixing. Then you fix it and do it again, as many times as you can. The more quickly you can build and fix the prototypes of the site, the more usable your website will be. So, as interaction designers, we are naturally drawn towards frameworks that make changes quick to implement, and Django is just such a framework, applied to the web.
Having said that…
There are, of course, specific tasks, and specific website applications which are made for each other, and needn’t involve Django. An obvious example is a blog: if all you need is a blog, use Wordpress or its ilk. If all you need is a social publishing site, use Drupal and let loose on the plugins. The caveat comes when you need something similar to a blog, but which does something a little different. Once you start going down that path, things go in one of two ways: 1: they get really hacky, really quickly, or 2: you spend huge resources implementing new plugins which solve the general case for all sites like yours (which is fine if you’re in the business of investing in such things–but consider also that this process is nearly automatic with Django apps). Take stock, and consider Django.
Recently I have been experimenting with hybrid approaches in two ways. First, I’m recommending that for sites above a certain level of complexity, Drupal or Plone is used to build a real quick prototype. Basically you continue adding plugins until you find what it is that the site can’t currently do. Then think about whether your required functionality is a) tiny enough to add as a hack or b) useful enough to develop a plugin for. If it’s neither of these, then consider making everything in Django. This will be a tough decision, since you have something close to the site right there, but trust me, the remaining 20% of the functionality will take 80% of the time.
The second hybrid approach I’ve been using is to combine a Wordpress install with a Django install. That’s because a lot of clients use a site admin mostly to publish news, and the Wordpress admin is really nicely set up for that (it helps that some of these clients are familiar with Wordpress already). Then I wrap a Django model around the Wordpress data tables, and use it to bring that data into the django site.
Finally, in a recent email discussion which, in part, prompted my post today, Tim said: “To some extent, these tools are all OK in the hands of people who are good with them. If you get Jeremy, use Drupal. If you get Greg, use Django. Getting a good developer and letting her use the tools she’s familiar with is, I think, more productive than trying to use the ‘right’ tool.” This is absolutely true. If you are commissioning a website, and hire an expert, and leave the tool choice to them. My points here are aimed at people who are choosing and using the tools.
What about Rails?
Django’s closest competitor is Ruby on Rails, and not without reason. Rails has been around longer and has greater momentum (or hype?). I dallied with it before Django, but it was harder to learn — I couldn’t get on with its ‘magic’. Maybe it’s just me, but I know Django went through a ‘magic-removal’ development phase, to make sure it didn’t do anything unasked. Rails also appears to have performance and scalability problems compared with Django, and appears to be harder to host. Sam Newman does a more thorough comparison here.
1. SQL is one of the few computing languages more verbose than the equivalent English!