2015-05-28 04:21:04 +00:00
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
|
|
|
|
class Person(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
friends = models.ManyToManyField('self')
|
|
|
|
|
|
|
|
|
|
|
|
class Number(models.Model):
|
|
|
|
person = models.ForeignKey(Person, related_name='numbers')
|
|
|
|
number = models.CharField(max_length=10)
|
|
|
|
|
|
|
|
|
|
|
|
class SSN(models.Model):
|
2015-05-28 12:41:14 +00:00
|
|
|
person = models.OneToOneField(Person, related_name='ssn')
|
2015-05-28 04:21:04 +00:00
|
|
|
number = models.CharField(max_length=10)
|
|
|
|
|
|
|
|
|
|
|
|
class Group(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
people = models.ManyToManyField(Person)
|