Skip to main content
  1. Dispatches/

Django Rocks My World

·851 words·4 mins
Articles assorted geekery development django tech python

So as I mentioned before I’ve been learning Python, and it has been a lot of fun. It says something that I can spend all day at work writing code, only getting up from the computer to scavenge the vending machines, but when the end of the day comes I find myself rushing home so that I can pick up where I left off in my Python lesson plan. I finished working my way through Dive Into Python a few days ago, which is an excellent introductory text if you already have a background in programming. If you are interested in Python, but new to programming, you might be better off with the text How To Think Like A Computer Scientist: Learning with Python. Both books are “open source” and available for free online reading.

There are a lot of things I really love about Python, dynamic yet strong typing, its capacity for introspection, the interactive interpreter, I could go on. Really what it comes down to is that Python is fun! It strips away unnecessary complexity and lets you dive right into the good stuff. I don’t know why it isn’t used more for instruction. I value the background my early training in Java and C++ gave me, but to be totally honest I rarely use either language anymore as their dynamic scripting language counterparts do everything I need and more. Maybe that makes me less of a programmer, but I don’t really care, because I can produce programs that work and perform just as well (or better) with less headache. I’ll take that any day. :)

So, since I was looking for a way to practice some of my Python I decided to take a look at the Django framework, which is a rapid development framework for Python powered web applications. My attention was drawn to it as there has been a lot of buzz about it of late, with Python users galore crying out that the framework is a “Rails killer”. Then the fires of fanboy love were fanned to a roaring blaze after a recent benchmark comparison between Django (Python), Rails (Ruby) and Symfony (PHP) frameworks, and Django came out in the lead by a lot. (Incidentally, due to some quirk of the wiki over at Ruby on Rails, you’ll need to go to their wiki first and then try to enter the URL or you’ll get error messages. Go figure.) It certainly got my attention however, so I decided to postpone my Ruby on Rails explorations while I checked out Django.

All I have to say is: Wow.

Django makes database-driven development so easy I almost feel dirty getting away with it. You define your database model in Python terms and run Django’s syncdb utility to automatically generate/modify database tables for all applications you want to set up in the current project. Afterwards, you can access your database records in you code as if they were Python objects, and the framework will do all the caching and querying the database for you via the object’s inherited methods. You can also write raw SQL if you need it, but to be honest I think most people will only require that in the most rare of cases. The database API is really powerful and dead simple to use as well.

One of the other great perks is that Django gives you a project administration interface for free! Uncomment one line of code and you have a customizable web interface for administration fully formed and ready for you. By default it allows you to manage users, sites, and application data. You can add records, edit them, view their relationships, search and filter, with form validation built in. It is quite impressive.

As I’ve be learning Django, I’ve been impressed with how easy their templating engine is, and how quickly you can put together a public interface for your applications. It really is very simple to write methods for each view which can then be called by their template. I can’t speak to real world performance yet, but in testing it has been quite snappy, and if the aforementioned benchmark is any indication I can probably expect this trend to continue.

In case you can’t tell, I’m pretty excited about this. I’ve only been playing with Django for a couple days, but I think I may be falling in love. :)

As far as referring to Django as a “Rails killer”, I’m not qualified to make that judgment as I haven’t worked with RoR yet. I will say that I find the tech community’s tendency to refer to every new product as the “[currently_most_popular_product] killer”* really annoying and particularly foolish. There’s room for all of them, and personally I just think that with all these amazing frameworks coming into being it is a great time to be a web developer. Our toolbox runneth over!

Now, if you’ll excuse me, I hear the siren song of Django calling me back to my text editor. :)

*Since I’m learning Python, I guess I should have written that as: "%s killer" % currently_most_popular_product.