2014-05-16 01:41:55 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
2008-07-19 07:54:34 +08:00
|
|
|
from django.db import models
|
2012-08-12 18:32:08 +08:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2008-07-19 07:54:34 +08:00
|
|
|
|
2010-10-14 09:40:20 +08:00
|
|
|
|
2008-07-19 07:54:34 +08:00
|
|
|
class School(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2013-11-03 12:36:09 +08:00
|
|
|
|
2008-07-19 07:54:34 +08:00
|
|
|
class Parent(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2013-11-03 12:36:09 +08:00
|
|
|
|
2008-07-19 07:54:34 +08:00
|
|
|
class Child(models.Model):
|
2015-07-22 22:43:21 +08:00
|
|
|
mother = models.ForeignKey(Parent, models.CASCADE, related_name='mothers_children')
|
|
|
|
father = models.ForeignKey(Parent, models.CASCADE, related_name='fathers_children')
|
|
|
|
school = models.ForeignKey(School, models.CASCADE)
|
2008-07-19 07:54:34 +08:00
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2013-11-03 12:36:09 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
@python_2_unicode_compatible
|
2009-04-01 03:55:20 +08:00
|
|
|
class Poet(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
def __str__(self):
|
2009-04-01 03:55:20 +08:00
|
|
|
return self.name
|
|
|
|
|
2013-11-03 12:36:09 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
@python_2_unicode_compatible
|
2009-04-01 03:55:20 +08:00
|
|
|
class Poem(models.Model):
|
2015-07-22 22:43:21 +08:00
|
|
|
poet = models.ForeignKey(Poet, models.CASCADE)
|
2009-04-01 03:55:20 +08:00
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
def __str__(self):
|
2009-04-01 03:55:20 +08:00
|
|
|
return self.name
|