December 15, 2011

Web Frameworks: When Love is Gone

Django and I were not meant to be.

For the last few months I've been trying to throw together a quick little site for my wife's photography hobby. Normally I reach for CodeIgniter (a PHP web framework) when I want to bang together a web site where an existing CMS doesn't quite fit the bill. CodeIgniter simply takes care of all the mundane stuff that you normally have to worry about when developing a web site or application. To use it, you simply extract the CodeIgniter tarball, perform some minor configuration, and point Apache at it. From there, you just add your models, views, controllers, templates, and static files. You can utilize any of the plentiful CodeIgniter helper libraries and classes if you happen to need or want them.

But where I work, Python is more or less the programming language of choice for anything that isn't primarily shell work (bash) or high-performance (C). Since I haven't used Python extensively for Serious Work, I thought I would give a Python web framework a try for this new project. Django came highly recommended, so I went with it. One thing I fell in love with immediately was Django's built-in customizable admin interface based around the app's models. Man, that's slick.

I followed the rather lengthy tutorial in the beginning and was encouraged. At the outset, it looked like Django was going to be a lot like CodeIgniter only "Pythonic" and with many more built-in features. But as dug into it, I found that the authors were explaining less as they went along, which forced me to wade through the Django documentation to get an idea of what was really going on. Now, the Django docs aren't bad per se but to me they read more like system specs than a teaching tool. I'm big on thorough, simple explanation, with plenty of examples. Maybe I'm just a bit thicker than your average Python hacker.

Anyway, tonight I drew the line. Django does not fit the bill for my fly-by-night one-off projects. At this point, I feel I've spent almost as much time reading (and re-reading) Django documentation as I would have in implementing the whole thing in PHP with CodeIgniter from the beginning. And that includes referencing the docs. The last straw was when I figured out a quirk of Django's static file handling by trial and error.

I spent about five hours trying to troubleshoot why the wrong CSS file was being loaded from a static files directory. I pored over docs. Googled here and there. Questioned my own sanity. A wild and almost random stab in the dark finally solved it, but the fact that it took so damn long and that the unexpected caveat doesn't seem to be mentioned anywhere in the docs (or at least, anywhere I thought to look) spoke volumes to me. On top of this, I just had a conversation with a good friend of mine a couple days ago about how highly I recommended CodeIgniter as a starting point for getting most any small- to mid-size app off the ground quickly.

Maybe Django is great for web developers crafting large production sites and who have all the time in the world to read docs and figure out the minutia of their intricate framework. But I don't, so it looks like Django and I will be parting ways, at least for now.