我有 2 个类的架构:
class Anomaly(DjangoObjectType):
class Meta:
model = models.Anomaly
class Batch(LoggedModel):
class Meta:
model = models.Batch
LoggedModel
在哪里
class LoggedModel(DjangoObjectType):
class Meta:
model = models.LoggedModel
最初都是继承自,DjangoObjectType
但后来两者都没有公开logs
模型超类中定义的字段
class LoggedModel(models.Model):
recursive_field = "parent_model"
logs = models.ManyToManyField(Log, related_name="%(app_label)s_%(class)s")
class Meta:
abstract = True
class Anomaly(LoggedModel):
...
class Batch(LoggedModel):
anomalies = models.ManyToManyField(Anomaly)
现在,在模式 Batch 中声明了 LoggedModel 的子类而不是 DjangoObjectType 之后,两个类的日志都公开了。任何人都可以解释一下吗?