2012-04-24 16:47:31 +00:00
|
|
|
from django.db import models
|
|
|
|
|
2013-11-02 21:34:05 +00:00
|
|
|
|
2012-04-24 16:47:31 +00:00
|
|
|
class Person(models.Model):
|
|
|
|
first_name = models.CharField(max_length=20)
|
|
|
|
last_name = models.CharField(max_length=20)
|
2018-07-11 08:18:41 +00:00
|
|
|
friends = models.ManyToManyField('self')
|
2018-07-11 20:37:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
# A set of models that use a non-abstract inherited 'through' model.
|
|
|
|
class ThroughBase(models.Model):
|
|
|
|
person = models.ForeignKey(Person, models.CASCADE)
|
|
|
|
b = models.ForeignKey('B', models.CASCADE)
|
|
|
|
|
|
|
|
|
|
|
|
class Through(ThroughBase):
|
|
|
|
extra = models.CharField(max_length=20)
|
|
|
|
|
|
|
|
|
|
|
|
class B(models.Model):
|
|
|
|
people = models.ManyToManyField(Person, through=Through)
|