2011-04-21 04:42:07 +08:00
|
|
|
from django.db import models
|
|
|
|
|
2011-10-14 02:04:12 +08:00
|
|
|
|
2017-06-30 04:00:15 +08:00
|
|
|
class Country(models.Model):
|
|
|
|
name = models.CharField(max_length=30)
|
|
|
|
|
|
|
|
|
2019-12-02 14:57:19 +08:00
|
|
|
class EUCountry(Country):
|
|
|
|
join_date = models.DateField()
|
|
|
|
|
|
|
|
|
2017-06-30 04:00:15 +08:00
|
|
|
class City(models.Model):
|
|
|
|
name = models.CharField(max_length=30)
|
|
|
|
country = models.ForeignKey(Country, models.CASCADE)
|
|
|
|
|
|
|
|
|
2019-12-02 14:57:19 +08:00
|
|
|
class EUCity(models.Model):
|
|
|
|
name = models.CharField(max_length=30)
|
|
|
|
country = models.ForeignKey(EUCountry, models.CASCADE)
|
|
|
|
|
|
|
|
|
2011-04-21 04:42:07 +08:00
|
|
|
class Person(models.Model):
|
|
|
|
name = models.CharField(max_length=30)
|
2017-06-30 04:00:15 +08:00
|
|
|
born = models.ForeignKey(City, models.CASCADE, related_name='+')
|
|
|
|
died = models.ForeignKey(City, models.CASCADE, related_name='+')
|
2017-10-17 11:28:00 +08:00
|
|
|
|
|
|
|
|
|
|
|
class PersonProfile(models.Model):
|
|
|
|
person = models.OneToOneField(Person, models.CASCADE, related_name='profile')
|