I have two models that I want to relate with a many to many relationship. BuildingGroup
and Building
My idea is that for example Building Group1 contains some Buildings and BuildingGroup2 contains other Buildings.
I think I should have set it up correctly, but the way it works now is that every BuildingGroup contains ALL of my Buildings, always. I can't delete a Building and selectively decide which building belongs to which group.
Here are my models:
class Building(models.Model):
name = models.CharField(max_length=120, null=True, blank=True)
def __str__(self):
return self.name
class BuildingGroup(models.Model):
description = models.CharField(max_length=500, null=True, blank=True)
buildings = models.ManyToManyField(Building, blank=True)
Is that the right way to set it up? And if so, how can I change it, so I can group it correctly??
Any help is highly appreciated!