This seems to be fairly simple but the solution doesn't feel intuitive enough to me. Could not find an SO post with this exact question though.
I have a School
model with a ManyToMany mapping to an Area
model which then has a OneToMany mapping to a SubArea
model.
class School(models.Model):
area = models.ManyToManyField(Area, blank=True)
sub_area = models.ManyToManyField(Area, blank=True)
class Area(models.Model):
name = models.CharField(max_length=100, unique=True)
class SubArea(models.Model):
name = models.CharField(max_length=100, unique=True)
area = models.ForeignKey(Area, blank=True)
A School
object can belong to one or more Area
s and optionally a specific SubArea
within an Area
but it doesn't feel quite intuitive to put sub_area
in the School
model because I feel that it should somehow be coming 'through' the area
field, though I could be wrong. Does the above seem like the ideal way to model this?