0

Is there a way to get all child classes of a django multi table inheritance?

Example:

class Parent(models.Model):
    pass

class ChildOne(Parent):
    pass

class ChildTwo(Parent):
    pass

I need a classmethod which returns [ChildOne, ChildTwo]

BTW: This question is not about automatic down casting :-)

guettli
  • 25,042
  • 81
  • 346
  • 663

1 Answers1

3

Check this link

[1]: How can I find all subclasses of a class given its name?

here used __subclasses__() method to find all subclasses of a class.

Community
  • 1
  • 1