select_related() does not work with inherited models
|Reported by:||langpavel||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
from django.db import models class BaseModel(models.Model): base_text = models.TextField() class InheritedA(BaseModel): textA = models.TextField() class InheritedB(BaseModel): textB = models.TextField()
Now, when I select BaseModel.objects.all() there is no (possible/easy) way to prefetch related models InheritedA and InheritedB with left outer join and reduce further queries to get each inherited instance of models.
When model inheritance is alowed and modeled as OneToOne relation, it should be possible to do optimization in same sense as select_related() do with foreign keys.