I have two models(classes) that one inherits from another. GRESubjectCertificate as parent
class GRESubjectCertificate(LanguageCertificate):
quantitative = models.PositiveSmallIntegerField()
verbal = models.PositiveSmallIntegerField()
analytical_writing = models.DecimalField(
max_digits=2, decimal_places=1,
)
total = models.PositiveSmallIntegerField()
and GREBiologyCertitficate as child:
class GREBiologyCertificate(GRESubjectCertificate):
cellular_and_molecular = models.PositiveSmallIntegerField()
organismal = models.PositiveSmallIntegerField()
ecology_and_evolution = models.PositiveSmallIntegerField()
I want to cast an object from GREBiologyCertificate to GRESubjectCertificate by parent class name in lower but it does not work. I have used before this solution to convert child object to parent object but now it fails.
instance1 = GREBiologyCertificate()
instance2 = instance1.gresubjectcertificate
'GREBiologyCertificate' object has no attribute 'gresubjectcertificate'
Edit1: Below example works without problem.
class A():
number = models.PositiveSmallIntegerField()
class B(A):
factor = models.PositiveSmallIntegerField()
instance1 = B()
instance2 = instance1.a
instance2 will be a instance of class A.