I have these three models :
Using Django's models system, how to represent the fact that a person is participating in a particular project with a specific role ?
general problem : What is the proper way to handle "ternary associations" using Django ?
I would do it using an intermediary model for m2m relationship and add a field there.
Something like this:
class Role(models.Model):
name = models.CharField(max_lenth=32)
class Project(models.Model):
name = models.CharField(max_lenth=32)
class PersonProject(models.Model):
person = models.ForeignKey('.Person')
project = models.ForeignKey(Project)
role = models.ForeignKey(Role)
class Person(models.Model):
projects = models.ManyToManyField(Project, through=PersonProject)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With