class Animal(models.Model):
....
class Meta:
abstract = True
class Cat(models.Model, Animal):
...
class Dog(models.Model, Animal):
....
You might be interested in django_polymorphic
Example from project docs:
When we store models that inherit from a Project
model...
>>> Project.objects.create(topic="Department Party")
>>> ArtProject.objects.create(topic="Painting with Tim", artist="T. Turner")
>>> ResearchProject.objects.create(topic="Swallow Aerodynamics", supervisor="Dr. Winter")
...and want to retrieve all our projects, the subclassed models are returned:
>>> Project.objects.all()
[ ,
,
]