Django and Rails

Jacob Kaplan-Moss

August 16, 2005

Sam Newman just posted a comparison of Django and Rails which is extremely balanced and fair, and a very good read. I’ve obviously got a few bits of feedback, so here goes:

Background

As a framework Rails has been around for little over a year, whereas as a framework in its own right django has only been public for around two months.

Actually, Django’s been in use internally for over two years, although we only got the buy-in from management to release it as open-source two months ago. So Django’s actually very stable and mature; a 1.0 release is more a matter of responding to community needs than fixing bugs.

Languages

On the face of it, the biggest difference between the two has been the choice of development language.

This is true, and I’m not going to even try to get into a Python versus Ruby argument. However, one of the things that draws me to Python is the great size of the “ecosystem” — there are a great number of awesome Python libraries that Django can leverage. A great example is the Django community page; the code that drives the aggregator is extremely simple thanks to Mark Pilgrim’s wonderful Universal Feed Parser. Being able to draw on all these wonderful Python libraries makes my job much easier.

Testing

My feeling is many people new to testing are more likely to do it with Rails because it’s built right in and it’s well documented.

A very good point; Django’s got a testing framework for Django itself, but a solid framework for tying tests into your models would be extremely useful.

Models

The only minor annoyance is that there is no equivalent of a model-specific SQL refresh - something that could drop a specific model’s tables and regenerate the needed SQL automatically. Instead you have to have the admin script dump out the SQL to the command prompt and run it in yourself.

I actually see this as a feature, not a bug. Dropping tables and regenerating the schema is one of those things that can result is horrible data loss if you’re not careful (yes, I do speak from past mistakes). I really like being able to get a look at any potentially destructive operation before it’s performed.

Django does seem to offer the ability to reverse-engineer models from an existing schema, although I don’t have information as to how sophisticated this is (for example to what extent it can determine inter-model relationships).

Right now it’s not as sophisticated as we’d like; it will neatly figure out the Django equivalents for each field type, and it will indeed follow inter-model relationships (although with many-to-many relationships it will explicitly create the join model, which is probably not what you want). However, The generated models do take a bit of massaging by hand to get working, but it’s a feature that’s in active development and should be nearly automatic by the time we’re done with it.

Again, thanks for the great article, Sam!

Comments:

ToddG:

I'm clearly tempting a smackdown here, being minimally up on Django compared to your "slightly" deeper involvement ;-) but anyhow...

I think the point of how long the two have been around is a bit pertinent, as although you guys no doubt pounded the heck out of Django, that's (internal use at Lawrence etc.) still a pretty limited exposure to use-cases compared to Rails' time out in the wild at this point.

I don't necessarily mean technical or code issues, but more so things like "no sharp edges" and the abstraction that develops from code being used for a zillion different things. I think the flurry of activity now that it's [Django] public is the best example of what I mean. So clearly it will improve greatly in this regard, but I do think there's a difference between time public and time internal, don't you?

Jacob:

ToddG: yeah, there clearly is a big different between internal and external use -- for example, Django only ran under Apache, mod_python and PostgreSQL until it hit the Real World™. Still, I think the fact that Django's been up and running for two years is worth noting as well.

(And I fixed the problem with comments being posted to the wrong entry; thanks).

Manuzhai:

Hmm, Jacob, don't you think your posts regarding Django belong on its community page as well? :)

Leave a comment:

Use your real name, or risk deletion.

Optional.

No markup allowed. Linebreaks will be converted; links will be linkified.

Be nice; don't be that guy.