Django inheritance

I have class Parent A (not abstract) and its children B, C and D.
The class A has a relation oneToOne with class E.

I know that Django create a oneToOne automatically to A with B or C or D when I create B or C or D.

Is it possible to query all B, C and D in one queryset with class E since class A has oneToOne relation with D, C and D?

Yes, you can use the select_related clause across either side of a OneToOne relationship to retrieve related entries in a single query.

(Side note: This topic should be classified under “Using Django” and not “Django Internals” since this is not a discussion about development of the ORM itself. You can click on the pencil next to the title and recategorize it.)

1 Like

Thanks, i will take a look