Using model inheritance

Django supports model inheritance. It works in a similar way to standard class inheritance in Python. Django offers the following three options to use model inheritance:

  • Abstract models: Useful when you want to put some common information into several models. No database table is created for the abstract model.
  • Multi-table model inheritance: Applicable when each model in the hierarchy is considered a complete model by itself. A database table is created for each model.
  • Proxy models: Useful when you need to change the behavior of a model, for example, by including additional methods, changing the default manager, or using different meta options. No database table is created for proxy models.

Let's take a closer look ...

Get Django 2 by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.