parts/django/tests/regressiontests/one_to_one_regress/models.py
changeset 307 c6bca38c1cbf
equal deleted inserted replaced
306:5ff1fc726848 307:c6bca38c1cbf
       
     1 from django.db import models
       
     2 
       
     3 class 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 
       
    10 class 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 
       
    18 class 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 
       
    25 class UndergroundBar(models.Model):
       
    26     place = models.OneToOneField(Place, null=True)
       
    27     serves_cocktails = models.BooleanField()
       
    28 
       
    29 class 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 
       
    36 class Target(models.Model):
       
    37     pass
       
    38 
       
    39 class Pointer(models.Model):
       
    40     other = models.OneToOneField(Target, primary_key=True)
       
    41 
       
    42 class Pointer2(models.Model):
       
    43     other = models.OneToOneField(Target)