The following code is given:
class BaseMedium(models.Model):
title = models.CharField(max_length=40)
slug = models.SlugField()
class A(BaseMedium):
The only way to do this is to explicitly store on the base model what type it is. So have a derived_type
(or whatever) field on BaseMedium, and set it on save. Then you can have a get_derived_type
method:
def get_derived_type(self):
if self.derived_type == 'A':
return self.a
elif self.derived_type == 'B':
return self.b
and so on.