PageRenderTime 47ms CodeModel.GetById 43ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/regressiontests/model_inheritance_select_related/models.py

https://code.google.com/p/mango-py/
Python | 29 lines | 17 code | 8 blank | 4 comment | 0 complexity | 568b49e569ae8a6320d2eb5af9630f92 MD5 | raw file
 1"""
 2Regression tests for the interaction between model inheritance and
 3select_related().
 4"""
 5
 6from django.db import models
 7
 8class Place(models.Model):
 9    name = models.CharField(max_length=50)
10
11    class Meta:
12        ordering = ('name',)
13
14    def __unicode__(self):
15        return u"%s the place" % self.name
16
17class Restaurant(Place):
18    serves_sushi = models.BooleanField()
19    serves_steak = models.BooleanField()
20
21    def __unicode__(self):
22        return u"%s the restaurant" % self.name
23
24class Person(models.Model):
25    name = models.CharField(max_length=50)
26    favorite_restaurant = models.ForeignKey(Restaurant)
27
28    def __unicode__(self):
29        return self.name