views:

23

answers:

1

Hello,

Let say I have 3 models: A, B and C with the following relations.

A can have many B and many C.

B can have many C

Is the following correct:

class A(models.Model):
  ...

class B(models.Model):
  ...
  a = models.ForeignKey(A)

class C(models.Model):
  ...
  a = models.ForeignKey(A)
  b = models.ForeignKey(B)

Or is there a more efficient way of doing this ?

+2  A: 

In short, yes. It's all correct, I have nothing to say. (On a side note, shouldn't that be models.ForeignKey(model_name) ?)

Aviral Dasgupta
yes, forgot when i cleaned up the code. Thanks.
Laurent Luce