I'm looking for a way to get a list of all classes that derive from a particular base class in Python.
More specifically I am using Django and I have a abstract base Model and then several Models that derive from that base class...
class Asset(models.Model):
name = models.CharField(max_length=500)
last_update = models.DateTimeField(default=datetime.datetime.now())
category = models.CharField(max_length=200, default='None')
class Meta:
abstract = True
class AssetTypeA(Asset):
junk = models.CharField(max_length=200)
hasJunk = models.BooleanField()
def __unicode__(self):
return self.junk
class AssetTypeB(Asset):
stuff= models.CharField(max_length=200)
def __unicode__(self):
return self.stuff
I'd like to be able to detect if anyone adds a new AssetTypeX model and generate the appropriate pages but currently I am maintaining a list manually, is there a way to determine a list of class names for anything that derives from "Asset"?