PageRenderTime 112ms CodeModel.GetById 51ms app.highlight 5ms RepoModel.GetById 55ms app.codeStats 0ms

/tests/regressiontests/admin_changelist/models.py

https://code.google.com/p/mango-py/
Python | 49 lines | 36 code | 13 blank | 0 comment | 0 complexity | 65a6d685f4eec99e66b4eadfba90d3d8 MD5 | raw file
 1from django.db import models
 2
 3class Parent(models.Model):
 4    name = models.CharField(max_length=128)
 5
 6class Child(models.Model):
 7    parent = models.ForeignKey(Parent, editable=False, null=True)
 8    name = models.CharField(max_length=30, blank=True)
 9
10class Genre(models.Model):
11    name = models.CharField(max_length=20)
12
13class Band(models.Model):
14    name = models.CharField(max_length=20)
15    nr_of_members = models.PositiveIntegerField()
16    genres = models.ManyToManyField(Genre)
17
18class Musician(models.Model):
19    name = models.CharField(max_length=30)
20
21    def __unicode__(self):
22        return self.name
23
24class Group(models.Model):
25    name = models.CharField(max_length=30)
26    members = models.ManyToManyField(Musician, through='Membership')
27
28    def __unicode__(self):
29        return self.name
30
31class Membership(models.Model):
32    music = models.ForeignKey(Musician)
33    group = models.ForeignKey(Group)
34    role = models.CharField(max_length=15)
35
36class Quartet(Group):
37    pass
38
39class ChordsMusician(Musician):
40    pass
41
42class ChordsBand(models.Model):
43    name = models.CharField(max_length=30)
44    members = models.ManyToManyField(ChordsMusician, through='Invitation')
45
46class Invitation(models.Model):
47    player = models.ForeignKey(ChordsMusician)
48    band = models.ForeignKey(ChordsBand)
49    instrument = models.CharField(max_length=15)