Django totally rocks
Monday, October 27th, 2008I must say: I’m impressed. Starting with the tutorial, I’ve been familiarizing myself with the Django framework for Python. In some ways, Django closely resembles popular MVC frameworks such a Ruby on Rails and CakePHP. However, Django is the only web framework (whether it’s MVC is up-for-debate and not worth discussing) that hits what I’ll call the ’sweet spot’ between doing everything a framework should do, and staying out of your way. Rails, despite its own claims of ’staying out of the way’, really likes to make you a sandwich.
I won’t even go into a comparison with CakePHP, Zend Framework, or .Net, because none of them treat query result sets as nicely as Rails and Django; instead, I’ll just breeze through a quick and only partly educated comparison with Rails.
Working in Django has the deliberate feel of home-cooking, with a speed & instant-gratification quotient similar to the more automat-like Rails. Generally speaking, you edit files, reload your browser, edit more files, reload your browser, etc. You don’t run a lot of code-generating scripts, and Django is not the dictator of your schema. Early in the process, you can just delete your database and have Django generate a new one as you schema evolves. While Django will add new columns and tables for you, it will never screw with existing entities. I see this as a Good Thing. Schema updates should become infrequent fairly early in a project, and tend to require semi-manual roll-out in production environments.
The default template system mirrors the beautiful simplicity of Python. View methods (analogous to Rails controller methods) call templates directly by filename. Templates, rather then relying on heavy nesting or repetition, extend other templates — just like subclasses extend parent classes. The brutal efficiency of the Form class means that virtually every node in an instance of Form is printable. If you print the whole instance, you get a generic form. If you print form.fieldname, you get a field or a group of fields appropriate for the datatype of fieldname (assuming you have generated your form object from a model). You can also print form.fieldname.label, form.fieldname.id, form.fieldname.label.id, etc. This may sound confusing, but the result is that you can start with a boilerplate form and use the same object as you enhance and customize your form in future iterations. It brings a tear to my eye…
And that’s really all I have to say about my Django experience so far. I love its simplicity, the consistency of its interfaces, and the general ethic of solid architecture and unobtrusive beauty