[Django]-How to queryset inheritance model django?


You can query with:


In Django model inheritance (of non-abstract models) is achieved by adding an implicit OneToOneField in the child model(s). We can thus use that relation by querying in reverse.

This will thus create a query that looks like:

SELECT final.*
FROM final
INNER JOIN parent ON final.parent_id = parent.id
INNER JOIN child1 ON parent.id = child1.parent_ptr_id
WHERE child1.att1 = 'abc'

Leave a comment