So, I've coded in Ruby on Rails for a while, and to tell you the truth, I thought it couldn't be better. But what do you know! Django is the framework I'm using right now. Just like that. I've swtched and I'm quite happy about it.
There are a few points I really like about Django. First of all, it follows the YagNI principle, or at least what I think is YagNI. When you generate a project using Django's manage.py script, it creates only a handful of files (four to be precise), and now I don't even need a complex IDE or editor plugin to help me hunt for files like I used to do in Rails. Now I spend most of my coding time in vim which has excellent support for Django.
Another thing is that Django is actually not an MVC framework. It's what Jacob, one of Django's lead developers called it in his Google TechTalk presentation, calls a MTV framework (the slide showed the Music Television logo at he was saying that, which, of course, led to much laughter). The MTV is short for Model-Template-View. The views in Django are similar to what Rails people term controller. But the difference seems superficial. Models, however, differ quite a bit, mostly thanks to the fact that Django has the website administration framework out of box. The way model data is presented in the admin section is coded in the models instead of controllers.
Organization of project files is much different than in Rails. In Rails, models are usually the only truly reusable parts of the application. However, a Django project consists of many applications, each with the full MTV (MVC) stack. The application is what is considered reusable, so developers are encouraged to abstract functionality into applications and integrate them into the project as loosely as possible. Even the routes (called simply URLs in Django) can be decoupled from the main routes file and placed into apps, so that individual apps can take care of their own routes.
The URL (routes) are defined using regular expressions, which may be offputting to newbies, but since every serious programmer is required to know at least a bit basic set of regular expressions, that is not a problem on the long run. It allows for much flexibility, and doesn't force you to use that framework thinks are right.
Just like the folder structure and files, Django doesn't generate much code for you. If you expected something like scaffold in Rails, be prepared to write more code yourself. But you do have the full admin section automagically created for you, so you can concentrate on writing stuff that matters to your users.
The Django shell (console in Rails) is sheer elegance. It's acts much the same way as any UNIX shell, except it is a Python shell that preloads your Django development environment. You have to see it to believe it, but I can tell you it's absolutely beautiful.
From a coder's perspective, Django has a whole lot less black-box feel to it. It's quite explicit, and there isn't much magic like there is in Rails. Some poeople prefer to have the framework take care of many details, but I personally felt Rails was handling too much. If you like to do more work yourself, than Django may be a better choice. From what I've heard from a Python-coding friend of mine, the Python community believes in "one right way of doing things", and you'll find that Django (and Python) code is more readable, simply because all developers do things more or less the same way. In Rails, I used to stumble upon snippets that did the same thing as mine, but in way I couldn't understand.
Well, everything I said above about Django is nothing compared to it's documentation. Django is not just a brutally efficient framework, but it's also well documented. I no longer have to hunt for docs in order to figure things up. The docs are right there on Django's website, along with a very nice 4-part tutorial (which will be expanded as the time goes), which quickly introduces you to basics of Django. And not just that. The tutorial gives you more than enough to start writing fully functional Django applications.
And a final note to newbies that might be considering Django. It is based on Python, but you can start writing Django projects with absolutetly no previous Python experience. Some things may look odd from time to time, but as you are getting used to them, you are actually learning more and more Python. Python itself is also well-documented, and you can even grab a bz2 file with PDFs of all docs and a tutorial.
Post new comment