django代理模型不止一个外键错误

时间:2013-05-20 12:56:04

标签: django

我的模型结构如下。

class SuperModel(models.Model):
    field_1 = models.CharField(max_length=20)

class child_A(supermodel):
  class Meta:
     proxy = True

class child_B(supermodel):
  class Meta:
     proxy = True

class Reference(models.Model):
  child_a = models.ForeignKey(Child_A, blank=True, null=True)
  child_b = models.ForeignKey(Child_B, blank=True, null=True)
  super_model = models.ForeignKey(Child_C, related_name=supermodel)

我实际上有4个儿童模特。我已经展示了2来说明问题。我保持super_model 所以我可以在没有检查所有孩子的情况下到达超级名模。只有一个孩子会引用超级名模。我在Reference has more than One Foreign key to Child_B.runserver时收到错误 有人可以指出错误。

编辑:super_model作为Reference中的一个字段,我保留了,所以我可以通过SuperModel的反向关系访问Reference。

0 个答案:

没有答案