# Model Inheritance Relations

**URL:** <https://forum.djangoproject.com/t/model-inheritance-relations/1708>\
**Category:** Using Django\
**Created:** [March 28, 2020, 11:40pm UTC](https://forum.djangoproject.com/t/model-inheritance-relations/1708 "2020-03-28T23:40:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bennolor](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/bennolor/32/2141_2.png) [@bennolor](https://forum.djangoproject.com/u/bennolor)\
**Post date:** [March 28, 2020, 11:40pm UTC](https://forum.djangoproject.com/t/model-inheritance-relations/1708/1 "2020-03-28T23:40:40Z")

</div>

How can one model polymorphism in django 3.0? I.E. I have a class `Vehicle` then I have the classes `Plane, Car, Tank, Bike` that all inherit the `Vehicle` class. Now I want to be able to select all Vehicles (aka getting the objects of all subclasses ( `Plane, Car, Tank, Bike` )) and set a subclass agnostic foreign key to Vehicles(i.e. a garage having a one to many relationship with vehicles)

Basically I either want django to recognize the Relationships OR I want to mirror all changes to tables of subclasses up to the `Vehicle` table, so I then have Each Car Bike etc also as a vehicle and find which object to select via a shared identifier.

---

<div class="post-metadata">

**Author:** ![adamchainz](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/adamchainz/32/26_2.png) [@adamchainz](https://forum.djangoproject.com/u/adamchainz)\
**Post date:** [March 29, 2020, 7:39am UTC](https://forum.djangoproject.com/t/model-inheritance-relations/1708/2 "2020-03-29T07:39:59Z")

</div>

Django supports 3 methods of model inheritance. You’re looking for multi-table inheritance: [https://docs.djangoproject.com/en/3.0/topics/db/models/#model-inheritance](https://docs.djangoproject.com/en/3.0/topics/db/models/#model-inheritance)

django-polymorphic can make it a bit easier to use in terms of selecting form the base class and gettign the subclasses back: [https://django-polymorphic.readthedocs.io/en/latest/](https://django-polymorphic.readthedocs.io/en/latest/)
