2008-06-29 09:39:32 +00:00
|
|
|
"""
|
|
|
|
Regression tests for the interaction between model inheritance and
|
|
|
|
select_related().
|
|
|
|
"""
|
2012-06-07 16:08:47 +00:00
|
|
|
from __future__ import unicode_literals
|
2008-06-29 09:39:32 +00:00
|
|
|
|
|
|
|
from django.db import models
|
2012-08-12 10:32:08 +00:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2008-06-29 09:39:32 +00:00
|
|
|
|
2011-10-13 21:34:56 +00:00
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
@python_2_unicode_compatible
|
2008-06-29 09:39:32 +00:00
|
|
|
class Place(models.Model):
|
|
|
|
name = models.CharField(max_length=50)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
ordering = ('name',)
|
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
def __str__(self):
|
2012-06-07 16:08:47 +00:00
|
|
|
return "%s the place" % self.name
|
2008-06-29 09:39:32 +00:00
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
@python_2_unicode_compatible
|
2008-06-29 09:39:32 +00:00
|
|
|
class Restaurant(Place):
|
2013-08-11 20:19:09 +00:00
|
|
|
serves_sushi = models.BooleanField(default=False)
|
|
|
|
serves_steak = models.BooleanField(default=False)
|
2008-06-29 09:39:32 +00:00
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
def __str__(self):
|
2012-06-07 16:08:47 +00:00
|
|
|
return "%s the restaurant" % self.name
|
2008-06-29 09:39:32 +00:00
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
@python_2_unicode_compatible
|
2008-06-29 09:39:32 +00:00
|
|
|
class Person(models.Model):
|
|
|
|
name = models.CharField(max_length=50)
|
|
|
|
favorite_restaurant = models.ForeignKey(Restaurant)
|
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
def __str__(self):
|
2008-06-29 09:39:32 +00:00
|
|
|
return self.name
|