Related models

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
class Country(models.Model):
code = models.CharField(max_length=3)
name = models.CharField(max_length=128)
capital = models.ForeignKey(City)
class City(models.Model):
name = models.CharField(max_length=128)
country = models.ForeignKey(Country)
population = models.IntegerField()