I have two models:
class University(models.Model):
name = models.CharField(max_length=50)
address = models.CharField(max_length=50, null=True, blank=True)
city = models.CharField(max_length=30, null=True, blank=True)
country = CountryField(null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
modified_at = models.DateTimeField(auto_now=True)
departments = models.ManyToManyField(Department)
class Department(models.Model):
name = models.CharField(max_length=50)
address = models.CharField(max_length=50, null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
modified_at = models.DateTimeField(auto_now=True)
I want to University
have many Departments
and vice versa which works fine.
But I also want to store more departments individually for one university.
For instance:
University1 has Department1 and Department2.
University2 has Department1.
I want those departments store individually for each university. Now when I update Department1, ofcourse every University which has that school will see changes. I don't want that. I want to update Department1 but only for the University1 record. Department1 in University2 shouldn't be updated.
I assume that adding through
option with intermediate model
wouldn't help. What's the best solution?