Ruby on Rails and Django

There was a need recently to start a new web application using Python as the development language.

Having spent most of the last few years developing using Ruby with Ruby on Rails, this presented a nice challenge.
So the first thing, that needed some research was to be able to find a web framework in Python that is as close as possible to Ruby on Rails.

A quick web framework comparison and some web searches, indicated that the closest framework to Ruby on Rails, was Django.

So here I intend to list the similarities and the differencies of the two frameworks, as I go along the route and discover new things. The initial impression after a couple of days is that there is a surprising similarity between them, which hopefully will make the road smoother.

  • MVC In the Ruby on Rails we have Models, Views and Controllers. In Django that becomes Models, Templates and Views.
  • Package installation While in Ruby on Rails we have gem install in Django that becomes pip install
  • RVM(rbenv) To keep ruby versions and gems in different environments in Ruby we could use RVM or rbenv. On Python that is virtualenv
  • In Ruby on Rails we have an application but in Django we have a project that can contain multiple applications
  • Create a new application Because of the note above in Rails we create a new application with rails new app_name, where in Django we create the project first with django-admin.py startproject project_name and then the application with python manage.py startapp app_name
  • Database configuration In Ruby on Rails the database configuration can be found in the config/database.yml. In Django the database configuration, among other configuration options, is in the file project_name/settings.py
  • Starting the development web server With Ruby on Rails is rails s, on Django is python manage.py runserver
  • Running the console In Rails we can use rails c, and in Django python manage.py shell
  • Route information While in Ruby on Rails we set the routes in config/routes, in Django that takes place in project_name/urls.py and in app_name/urls.py
  • Deployment automation Capistrano for Ruby on Rails and Fabric for Django
  • Dependencies file is the Gemfile in Ruby on Rails and requirements.txt in Python’s virtualenv