Django: I want to connect about one-to-many...
What should I do?
from django.db import models
class Note(models.Model)
content = models.CharField(max_length=20)
class A(models.Model)
name = models.CharField(max_length=20)
addr = models.CharField(max_length=20)
notes = models.ManyToManyField(Note) # ...? I don't know...
class B(models.Model)
nickname = models.CharField(max_length=20)
mobile = models.CharField(max_length=20)
notes = models.ManyToManyField(Note) # ...? I don't know...
Note model : A model = 1 : N... Note model : B model = 1 : N...
I want to connect Note - A at the same time Note - B...
Please answer me!
Thank you!
Edit 130208 8:36 KST----
Maybe ForegienKey is available...
But my case can't use that.
Because if I want only connection(ex. Note to A), I can do it like the code below.
from django.db import models
class Note(models.Model)
content = models.CharField(max_length=20)
conn = models.ForeignKey(A)
class A(models.Model)
name = models.CharField(max_length=20)
addr = models.CharField(max_length=20)
But my case need two connection(Note - A, Note - B).
So.... I don't know what should I do...