1

I have a model:

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'])

and

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

So how can I add Financials as a child to Company in the mptt tree structure?

Carl Meyer
  • 122,012
  • 20
  • 106
  • 116
  • This question should be closed as a duplicate of http://stackoverflow.com/questions/507006/problem-using-django-mptt – Carl Meyer Feb 04 '09 at 17:36
  • I asked a similar question here: http://stackoverflow.com/questions/291249/django-how-do-i-model-a-tree-of-heterogeneous-data-types – Corey Feb 04 '09 at 17:38

1 Answers1

1

I don't quite follow your question. A tree stores one type of object, in your case Company. To link Financials to Company just add a foreign key from Financials to Company.

If this doesn't help please expand your question to give us some more detail about what you are trying to achieve.

Andrew Wilkinson
  • 10,682
  • 3
  • 35
  • 38