1 from django
.db
import models
4 class Part(models
.Model
):
5 name
= models
.CharField(max_length
=20)
10 def __unicode__(self
):
13 class Car(models
.Model
):
14 name
= models
.CharField(max_length
=20)
15 default_parts
= models
.ManyToManyField(Part
)
16 optional_parts
= models
.ManyToManyField(Part
, related_name
='cars_optional')
21 def __unicode__(self
):
25 price
= models
.IntegerField()
27 class Person(models
.Model
):
28 name
= models
.CharField(max_length
=20)
29 fans
= models
.ManyToManyField('self', related_name
='idols', symmetrical
=False)
30 friends
= models
.ManyToManyField('self')
35 def __unicode__(self
):