What are the tradeoffs of using Abstract Base Classes vs Multi-table Inheritance in Django models?
Last updated
Abstract base classes (
abstract = True) copy parent fields into each child table: no parent table and no joins, so they are fast. But you can't query all children together or FK to the parent.Multi-table inheritance gives the parent its own table linked to each child by an implicit
OneToOneField. The parent is queryable and can be an FK target, but reads need joins and writes touch two tables.Rule of thumb: use abstract for reusing fields like
created_at. Use MTI only when you truly need a shared queryable parent.
- https://www.geeksforgeeks.org/python/django-interview-questions/
- https://foysalff.medium.com/12-advanced-django-interview-questions-for-experienced-developers-dbe654e21a45
- https://www.careers360.com/courses-certifications/articles/django-interview-questions-and-answers
- https://www.interviewbit.com/django-interview-questions/
- https://www.youtube.com/watch?v=OuBUUkQfBYM
- https://www.placementpreparation.io/blog/django-interview-questions-for-freshers/