This has been discussed, at length, and rejected. If you search the
django-dev archives, the discussion happened around the time that
model inheritance was being added to the ORM. For the most part,
you're looking for a series of discussions between myself and Malcolm.
Using "CORBA" as a keyword in your search will help (and if you know
anything about CORBA, will also explain why the idea was ultimately
rejected).
The techniques to achieve this sort of thing are well known and well
established, but they do come at a cost. We opted not to wear that
cost by default in inherited models. If you want this capability, it
(or something functionally equivalent) can be added as an end-user
add-on to models.
Yours,
Russ Magee %-)
So seems that this idea was in fact rejected because of the O(# of
nodes in the inheritance tree) joins
needed to get all the fields from subclass tables.
When I said before that it was possible to emulate this in user space,
I meant you could do something like the following:
* Add a klass column to your base model.
* On subclasses, populate this column with a class-specific identifying value.
* Add a narrow() function (naming borrowed from CORBA) on the base
class that uses the value of klass to determine the subclass instance
that needs to be retrieved
* Whenever you need a list of subclasses, use a list comprehension
that incorporates narrow:
[ obj.narrow() for obj in BaseClass.objects.all() ]
It's not spectacularly efficient - it does lots of joins and lots of
database traffic, but it works.
> Or if this is planned for some future release.
As I said previously, this isn't planned for a future release - in
fact, it's planned that we _wont_ do this.
Yours,
Russ Magee %-)
If, by "one single and only DB query", you mean a single Django ORM
query - you are correct.
Yours,
Russ Magee %-)