models.py 442 B

12345678910111213141516
  1. from django.db import models
  2. class Country(models.Model):
  3. name = models.CharField(max_length=30)
  4. class City(models.Model):
  5. name = models.CharField(max_length=30)
  6. country = models.ForeignKey(Country, models.CASCADE)
  7. class Person(models.Model):
  8. name = models.CharField(max_length=30)
  9. born = models.ForeignKey(City, models.CASCADE, related_name='+')
  10. died = models.ForeignKey(City, models.CASCADE, related_name='+')