The Ins and Outs of Model Inheritance

Wednesday 12:20 pm to 12:50 pm, in Salon A-E

About This Talk

Have you ever used model inheritance and been surprised by the resulting database schema and queries that were generated? Or perhaps you have lived by the age-old Object Oriented design mantra suggesting that one must “favor composition over inheritance” and wondered why the Django Object Relational Mapping (ORM) provides not just one but, three different styles of model inheritance!

In this talk, we will start with an overview of Django models and then take an in-depth look at:

  • Abstract Models
  • Multi-table Inheritance (Concrete Inheritance)
  • Proxy Models (Single-table Inheritance)

In addition to discussing best practices and the potential pitfalls of each approach, we will dive under the hood and examine the database mappings and query results Django creates. We will discuss helpful toolkits and libraries such as those that can perform downcasting. And of course, we will spend ample time discussing when to choose inheritance over alternate design patterns such as composition with foreign keys.

This talk is designed primarily for folks with some familiarity with an ORM and/or any relational database. However, if you are curious about model inheritance, excited by data modeling and model design patterns, or interested in exploring the underlying database tables and queries generated by Django, then this adventure is for you!


    Blythe J Dunham