David 天宇 Wong
David 天宇 Wong

Reputation: 4197

Why are django SQL tables singular when RoR's are plurals?

I learned on rails that you should call your tables "posts" and "comments" and etc...

But I'm learning Django right now and it seems that application names are plural when tables and models are singular.

Is there a special reason behind that?

Upvotes: 2

Views: 298

Answers (1)

zwippie
zwippie

Reputation: 15515

Someone should correct me here because I'm not sure, but I think what matters is that Django lacks (or deliberately does not support) inflection. I Googled for django inflector but did not find anything related to the Django core. Searching for rails inflector yielded more.

Snippet from the Rails docs:

The Inflector transforms words from singular to plural, class names to table names, modularized class names to ones without, and class names to foreign keys. The default inflections for pluralization, singularization, and uncountable words are kept in inflections.rb.

Although I am a Rails person, I do not really have a strong opinion about the difference in table name treatment; tomatoes tomatos. When working with frameworks like Rails or Django, most of the time you just want to stick with their conventions and best practices.

Upvotes: 1

Related Questions