2008-07-18 23:54:34 +00:00
|
|
|
from django.db import models
|
|
|
|
|
2010-10-14 01:40:20 +00:00
|
|
|
|
2008-07-18 23:54:34 +00:00
|
|
|
class School(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2013-11-02 23:36:09 -05:00
|
|
|
|
2008-07-18 23:54:34 +00:00
|
|
|
class Parent(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2013-11-02 23:36:09 -05:00
|
|
|
|
2008-07-18 23:54:34 +00:00
|
|
|
class Child(models.Model):
|
2015-07-22 09:43:21 -05: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-18 23:54:34 +00:00
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2013-11-02 23:36:09 -05:00
|
|
|
|
2009-03-31 19:55:20 +00:00
|
|
|
class Poet(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2009-03-31 19:55:20 +00:00
|
|
|
return self.name
|
|
|
|
|
2013-11-02 23:36:09 -05:00
|
|
|
|
2009-03-31 19:55:20 +00:00
|
|
|
class Poem(models.Model):
|
2015-07-22 09:43:21 -05:00
|
|
|
poet = models.ForeignKey(Poet, models.CASCADE)
|
2009-03-31 19:55:20 +00:00
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2016-03-24 20:04:25 -04:00
|
|
|
class Meta:
|
|
|
|
unique_together = ("poet", "name")
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2009-03-31 19:55:20 +00:00
|
|
|
return self.name
|