from django.db import models class Continent(models.Model): name = models.CharField(max_length=30, unique=True) code = models.CharField(max_length=2, unique=True) class Meta: ordering = ["name"] def __str__(self): return "%s -- %s" % (self.name, self.code) class Country(models.Model): name = models.CharField(max_length=30, unique=True) code = models.CharField(max_length=2, unique=True) capital = models.CharField(max_length=30) population = models.PositiveIntegerField() area = models.PositiveIntegerField() continent = models.ForeignKey("Continent", related_name="countries") class Meta: ordering = ["name"] def __str__(self): return "%s -- %s -- %s -- %s -- %s -- %s" % ( self.name, self.code, self.capital, self.population, self.area, self.continent)