Blog

Rails vs. Django: a Beginners Point of View

For an agile web developer two frameworks are available for quick and easy deployment of a new website:

Ruby on Rails for the Ruby fans and Django for the Python fans. These two tools should provide the same functionality and as someone whos been working on two projects for the last month, each using one the frameworks, I have had the experience of starting from scratch on both of them and trying to learn both in parallel (or at least one right after the other without acquiring more experience in one and becoming biased for one over the other).

So what has this experience taught me?

Deployment

It is very easy to start an application using both Rails or Django: rails myapp vs. django-admin.py startproject mysite even though one is wordier than the other it is pretty simple to start the project with all the directories and files needed automatically generated.

Starting the Server

This task is as simple as the previous one: ruby script/server vs. python manage.py runserver in both cases there is a call to the language in use, then passing a command. In Rails case the command is an executable found in the script directory whereas in Django’s case the command is an argument passed to the Python manager.

Configuration

Both frameworks provide a place to configure the application. Rails provide an entire directory to configure the database setup and the Rails environment whereas Django provides a settings.py file where all the configurations can be present but also provides the option of having a config directory for multiple personalized configurations.

Updating the Database

Yet another simple task: rake db:migrate vs. python manage.py syncdb In this case we notice that with Rails the call is actually to rake whereas for Django it is still consistent with the previous format. But well see that Rails is also consistent where rake is called for everything relating to the database.

Creating Models

Where some of the differences begin: With Rails you create one application that can have multiple controllers, models and models and link to each other usingruby script/generate * (where the * differs depending on what needs to be generated). Whereas in Django you create multiple applications which each has its own models and views using python manage.py startapp myapp

Documentation

It seems that Rails is more widely used which results in more available resources online for documentation and help. None the less, the Django documentation site is very extended and provides sufficient help.

The Dirt

In the case of Rails I started the project from scratch by first following with the example in the book Agile Web Development with Rails, Third Edition and then applying what I learned to the project I was working on. Whereas in the case of the Django project, I was put on it late in the development process and tried to learn the language and at the same time understand what was already done on the project. My experience with both has been limited and what I have found is that the Rails magic seems to be the difference maker for most people. The majority are not comfortable with that “unknown” but I have seen some magic done with other languages like Java, although it is not the same type but in either case there is something in the background that is doing some sort of work for the programmer. And I have become comfortable with such a setting and because I have seen a bit of how programming languages interpreters work I understand and appreciate the Rails magic. Even though I was more productive using Rails than I was using Django, which may have influenced my opinion about them, I am still willing to give Django a chance. Both are great tools for developing web applications in an agile manner. My recommendation though, if I have to make one, will go for Ruby on Rails, just because I was more comfortable with it.