Am 26.05.2014 00:50, schrieb Craig de Stigter:
If you ignore STI, I think it is quite straightforward to solve this with a
parent model class which adds a type field, and manager methods to add the
select_related calls and "interpret" the type field properly; so I don't see an
immediate need for inclusion in core.
Well, you don't need select_related calls at all, if you're actually storing things
in one table like "single-table
inheritance" implies.
I too was surprised to find Django doesn't do this, and was unable to find a
good third-party app that does it.
So I wrote my own: https://github.com/craigds/django-typed-models/
It works well and we have been using it in production for a couple years.
...
Thank you very much for your answer.
I guess a lot of developers don't want to hear the next lines:
I think it is a "not invented here" syndrome: Ruby on Rails did it before.
That's
a reason to do it different.
But I can live with an external library like django-typed-models. It does not
need to be in django core.
There is a second fear: Some years ago, when I was new to database layout
design I tried
to avoid to create new tables. And I guess a lot of other did it like this,
too. If you
could use some tricky algorithm to avoid a database table, I choose to code,
not to
use a new table.
Time has passed and I learned: Structure is more important, code can be
replaced.
If I can write less code with a good database layout now, I prefer less code.
Django
ORM and south handles new tables perfect.
New tables is an expansion in one dimension, the other dimension is: new
columns.
That's what STI does: it creates a lot of new columns. When I first read how
STI works,
I had the same old fear: New columns .... that is outside my current comfort
zone.
I want to use STI the next time I need model inheritance.
Regards,
Thomas
--
Thomas Güttler
http://thomas-guettler.de/
--
You received this message because you are subscribed to the Google Groups "Django
developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/539170D7.8090509%40tbz-pariv.de.
For more options, visit https://groups.google.com/d/optout.