from django.db import models
from audit_trail.audit import AuditTrail
from my_base_model.classes import BaseUuidModel
from my_class_base import BaseClass
class Mini(BaseMaternalVisitModel):
my_class_base = models.ForeignKey(BaseClass)
class MiniHu(BaseUuidModel):
myclass = models.ForeignKey(Mini)
class Meta:
app_label="classes"
when I run python manage.py validate I get this error
<MiniHu> has a relation with model <Mini>, which has either not been installed or is abstract.
Have you ran
python manage.py syncdbto create the necessary database tables? You also mention theMiniclass is a subclass ofBaseMaternalVisitModel, which you have not imported here (though if you’re getting that error I’m guessing you just forgot that line when you posted here).When you’re subclassing Django models you should be aware of the difference between “normal” models and “abstract” models. When a model is “abstract” it is not created with
syncdb— only when you subclass it, in which case only the subclassed model is created in the database, containing all its own fields and the ones it inherited from its parent class: the abstract class. This is the reason for the “not been installed or is abstract” error: abstract models don’t exist as far as the database is concerned. Django is trying to access a model in the database that doesn’t exist: either because you haven’t ransyncdband created it or because it is an abstract model and doesn’t exist in the database.