我收到自引用 FK 使用假对象测试 django 的典型运行时错误:
... last 4 frames repeated, from the frame below ...
/home/cchilders/.virtualenvs/clientsite/lib/python3.4/site-packages/model_mommy/mommy.py in make(model, _quantity, make_m2m, **attrs)
96 return [mommy.make(**attrs) for i in range(_quantity)]
97 else:
---> 98 return mommy.make(**attrs)
99
100
RuntimeError: maximum recursion depth exceeded while calling a Python object
该模型:
class ItemGroup(models.Model):
parent = models.ForeignKey('self', db_column='parent_id')
name = models.CharField(max_length=255)
value = models.CharField(max_length=255, unique=True)
class Meta:
db_table = u'item_groups'
def __str__(self):
return self.value
def __repr__(self):
return '<{} {}: {}>'.format(self.__class__.__name__, self.pk, self.value)
将自己称为 FK 的文档很少。你怎么能用modelmommy伪造一个需要自己的实例?谢谢