django model relation definition

Posted by Laurent Luce on Stack Overflow See other posts from Stack Overflow or by Laurent Luce
Published on 2010-05-05T00:47:08Z Indexed on 2010/05/05 0:48 UTC
Read the original article Hit count: 318

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 = ForeignKey(A)

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

© Stack Overflow or respective owner

Related posts about django-models

Related posts about foreign-key