The basics of creating a tumblelog with Django (via) Ryan Berg suggests having a StreamItem model that links uses a GenericForeignKey to link to other content types, then using signals to cause a StreamItem to be created for every other model type. I should switch to doing that on this blog: at the moment I have to query three separate tables to build the tumblelog part which results in messy code for ordering and pagination.
James, someone just asked the same question at the original post. Model inheritance wasn't around when I began writing this code, but I can certainly see it being used successfully for a tumblelog.
My question, since I'm not that familiar with model inheritance yet, is how you can use that inheritance with models you don't have the ability (or shouldn't) modify, like from a contrib app or maybe a third party library?
Ryan Berg - 26th June 2008 04:26 - #
I'm not hugely familiar with it myself, but it sounds like multi table inheritance would handle that fine. The parent class has it's own table, separate from child classes, and the two are related with an automatic OneToOne field.
The other type of model inheritance involves abstract classes that don't correspond to tables and serve only to be extended.
The whole point of inheritance is you don't modify the parent, you extend it with extra functionality.