PageRenderTime 62ms CodeModel.GetById 40ms app.highlight 4ms RepoModel.GetById 16ms app.codeStats 0ms

/tests/modeltests/m2m_signals/models.py

https://code.google.com/p/mango-py/
Python | 36 lines | 25 code | 11 blank | 0 comment | 0 complexity | 521244c85fb85ee958e47dd60f434399 MD5 | raw file
 1from django.db import models
 2
 3
 4class Part(models.Model):
 5    name = models.CharField(max_length=20)
 6
 7    class Meta:
 8        ordering = ('name',)
 9
10    def __unicode__(self):
11        return self.name
12
13class 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')
17
18    class Meta:
19        ordering = ('name',)
20
21    def __unicode__(self):
22        return self.name
23
24class SportsCar(Car):
25    price = models.IntegerField()
26
27class 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')
31
32    class Meta:
33        ordering = ('name',)
34
35    def __unicode__(self):
36        return self.name