Opened 15 years ago

Closed 15 years ago

#12145 closed (duplicate)

select_related() does not work with inherited models

Reported by: Pavel Lang Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Keywords: select_related
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Example code:

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.

Change History (1)

comment:1 by Alex Gaynor, 15 years ago

Resolution: duplicate
Status: newclosed

This is a duplicate of #7270.

Note: See TracTickets for help on using tickets.
Back to Top