PageRenderTime 101ms CodeModel.GetById 40ms app.highlight 4ms RepoModel.GetById 56ms app.codeStats 0ms

/tests/regressiontests/one_to_one_regress/models.py

https://code.google.com/p/mango-py/
Python | 43 lines | 31 code | 12 blank | 0 comment | 0 complexity | ae517fed1f295e1243460881e87e0f14 MD5 | raw file
 1from django.db import models
 2
 3class Place(models.Model):
 4    name = models.CharField(max_length=50)
 5    address = models.CharField(max_length=80)
 6
 7    def __unicode__(self):
 8        return u"%s the place" % self.name
 9
10class Restaurant(models.Model):
11    place = models.OneToOneField(Place)
12    serves_hot_dogs = models.BooleanField()
13    serves_pizza = models.BooleanField()
14
15    def __unicode__(self):
16        return u"%s the restaurant" % self.place.name
17
18class Bar(models.Model):
19    place = models.OneToOneField(Place)
20    serves_cocktails = models.BooleanField()
21
22    def __unicode__(self):
23        return u"%s the bar" % self.place.name
24
25class UndergroundBar(models.Model):
26    place = models.OneToOneField(Place, null=True)
27    serves_cocktails = models.BooleanField()
28
29class Favorites(models.Model):
30    name = models.CharField(max_length = 50)
31    restaurants = models.ManyToManyField(Restaurant)
32
33    def __unicode__(self):
34        return u"Favorites for %s" % self.name
35
36class Target(models.Model):
37    pass
38
39class Pointer(models.Model):
40    other = models.OneToOneField(Target, primary_key=True)
41
42class Pointer2(models.Model):
43    other = models.OneToOneField(Target)