Django: My Framework of Choice

I am a web developer by trade, and like any skilled worker, I am always looking for the best tools for the job. With my current job, I write PHP on top of a custom in-house CMS. Off the clock though, I work with Python and Django.

First off, I like the concept of a framework. With web development, 95% of the stuff you do is stuff you've done before and unavoidably will do again. A well-written framework alleviates a lot of this. Most of the tasks can be broken down to 2 steps: 1) Grab objects from database. 2) Show them. The visual design of a website is always the fun part to do after you get all the heavy lifting done. There are also things like form handling, user authentication, writing XML feeds, and caching that gets done over and over that frameworks are nice enough to say, “hey, I'll take care of this boring, repetitive stuff and let you get on with creating something cool.”

As far as specific frameworks go, I've read quite a bit about Ruby on Rails and wrote some simple apps to test it out. One reason I didn't grasp on to this one was that I didn't know Ruby. Another reason is that deploying it seemed tricky and you trade speed of deployment for runtime speed. This is true for any interpreted language, but Ruby on Rails takes it to the extreme in both directions. Also it seems too opinionated at times stepping in the way of what I really wanted to do.

Another one I've gave more than a passing glance to is CakePHP. While there are several good ideas in there, and it does increase coding efficiency, it has one big, glaring black mark against and that is it is writting in PHP. PHP is a good language in the regards that it fairly powerful, runs everywhere, runs relatively fast, and everyone knows it, but it is an unattractive and inconsistent language. This link sums it up quite nicely.

Now onto my favorite: Django. When I first stumbled on this one earlier this year, I amazed by the simplicity of the framework and how it just made sense, from organizational and logical standpoints. There is a very strict model/view/controller demarcation (except Django calls the controller a view, and the view a template) which leaves little debate of what piece of code goes where, which in my opinion is a great thing. It also has lots of super handy things that are built in or are easily added, such as an auto-admin interface, unit and regression testing, modular apps, an easy-to-use templating language, great form handling, and user authentication.

Far and away my favorite features are the generic views. In my opinion, most of web development is grab an item or a list of items from the database and show them on a page, possibly paginating if there are a lot of them or maybe dividing them up by their publication dates. With generic views, Django takes almost all of this repetitiveness and abstracts it out so you can get on with making it look pretty or adding some cool new feature. Django brings back a lot of the joy of web development that sometimes gets lost in the grind or when writing that same hunk of logic for the hundredth time.

Not to be one to follow hype, I didn't fully buy into Django until I built a full site with it. Meghan and I built a soon to be launched site for our upcoming wedding. We built it from the ground up (with Django, of course) in the span of about 3 hours. This time included everything from registering the domain to designing the site. It even has a working blog with a commenting system, and a full-featured admin tailored to my exact needs. Django made the easy things really easy and the hard or repetitive things actually fun to work with.