1

我有一个模型:

class Company(models.Model):
    name = models.CharField( max_length=100)
    parent = models.ForeignKey('self', null=True, blank=True, related_name='children')
mptt.register(Company, order_insertion_by=['name'])

class Financials(models.Model):
    year = models.IntegerField()
    revenue = models.DecimalField(max_digits = 10, decimal_places = 2)

那么我怎样才能在 mptt 树结构中添加Financials一个孩子呢?Company

4

1 回答 1

1

我不太明白你的问题。一棵树存储一种类型的对象,在您的情况下为公司。要将财务链接到公司,只需将外键从财务添加到公司。

如果这没有帮助,请扩展您的问题,向我们提供有关您要实现的目标的更多详细信息。

于 2009-02-04T10:45:07.047 回答