B.3. Django

Django (www.djangoproject.com) isn't a Ruby clone at all, but a project that became public in a similar time frame using a similar set of design principles. Django is written in Python and includes an ActiveRecord-like mechanism for associating Python classes to database tables. Unlike Rails, where you define the database tables and the models are inferred, in Django, you define the model objects and the database table is inferred. Django also has a flexible URL routing system and a powerful template language. Django does not directly support an Ajax framework, but it allows users to select their own Ajax tool to use within the Django application.

Django is an interesting comparison to Rails because although similar design principles were at work, the two tools came out of very different environments and constraints, which have led to some sharp differences in how the tools are structured. Rails was developed by a small business company to support building a small number of different sites. Django was developed by a media company to allow rapid creation of a number of different content-management kinds of sites. For example, Django maintains a common admin site for all applications, which is important in a newsroom content system, but which was not a necessity for early Rails projects. Conversely, Ajax was much more important to the early development of Rails.

Get Professional Ruby on Rails™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.