In Django I have theses models:
class Artist(models.Model):
name = models.CharField(max_length=128)
born_place = models.ForeignKey(???)
dead_place = models.ForeignKey(???)
live_places = models.ManyToManyField(???)
work_places = models.ManyToManyField(???)
class Country(models.Model):
iso = models.CharField(max_length=2, primary_key=True)
name = models.CharField(max_length=50)
class Region(models.Model):
iso = models.CharField(max_length=2, blank=True)
name = models.CharField(max_length=150)
country = models.ForeignKey('Country')
class City(models.Model):
name = models.CharField(max_length=150)
region = models.ForeignKey('Region')
All the places (born_place
, dead_place
, live_places
, work_places
) can be a City
or a Region
or a Country
. And a City
should necessarily have a Region
, and a Region
should necessarily have a Country
.
How can I achieve that?