2009-03-22 09:45:22 +08:00
|
|
|
"""
|
|
|
|
Regression tests for defer() / only() behavior.
|
|
|
|
"""
|
|
|
|
|
2011-07-13 17:35:51 +08:00
|
|
|
from django.db import models
|
2012-08-12 18:32:08 +08:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2009-03-22 09:45:22 +08:00
|
|
|
|
2011-10-14 02:51:33 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
@python_2_unicode_compatible
|
2009-03-22 09:45:22 +08:00
|
|
|
class Item(models.Model):
|
2009-04-04 11:21:31 +08:00
|
|
|
name = models.CharField(max_length=15)
|
2009-03-22 09:45:22 +08:00
|
|
|
text = models.TextField(default="xyzzy")
|
|
|
|
value = models.IntegerField()
|
|
|
|
other_value = models.IntegerField(default=0)
|
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
def __str__(self):
|
2009-03-22 09:45:22 +08:00
|
|
|
return self.name
|
|
|
|
|
2013-11-03 06:50:35 +08:00
|
|
|
|
2009-04-04 11:21:31 +08:00
|
|
|
class RelatedItem(models.Model):
|
|
|
|
item = models.ForeignKey(Item)
|
|
|
|
|
2013-11-03 06:50:35 +08:00
|
|
|
|
2014-02-15 19:24:20 +08:00
|
|
|
class ProxyRelated(RelatedItem):
|
|
|
|
class Meta:
|
|
|
|
proxy = True
|
|
|
|
|
|
|
|
|
2009-04-04 13:34:23 +08:00
|
|
|
class Child(models.Model):
|
|
|
|
name = models.CharField(max_length=10)
|
|
|
|
value = models.IntegerField()
|
|
|
|
|
2013-11-03 06:50:35 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
@python_2_unicode_compatible
|
2009-04-04 13:34:23 +08:00
|
|
|
class Leaf(models.Model):
|
|
|
|
name = models.CharField(max_length=10)
|
|
|
|
child = models.ForeignKey(Child)
|
2009-04-04 13:35:01 +08:00
|
|
|
second_child = models.ForeignKey(Child, related_name="other", null=True)
|
2009-04-04 13:34:23 +08:00
|
|
|
value = models.IntegerField(default=42)
|
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
def __str__(self):
|
2009-04-04 13:34:23 +08:00
|
|
|
return self.name
|
|
|
|
|
2013-11-03 06:50:35 +08:00
|
|
|
|
2009-12-22 23:18:51 +08:00
|
|
|
class ResolveThis(models.Model):
|
|
|
|
num = models.FloatField()
|
|
|
|
name = models.CharField(max_length=16)
|
2011-05-15 08:56:01 +08:00
|
|
|
|
2013-11-03 06:50:35 +08:00
|
|
|
|
2011-05-15 08:56:01 +08:00
|
|
|
class Proxy(Item):
|
|
|
|
class Meta:
|
|
|
|
proxy = True
|
2011-07-18 06:22:39 +08:00
|
|
|
|
2013-11-03 06:50:35 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
@python_2_unicode_compatible
|
2011-07-18 06:22:39 +08:00
|
|
|
class SimpleItem(models.Model):
|
|
|
|
name = models.CharField(max_length=15)
|
|
|
|
value = models.IntegerField()
|
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
def __str__(self):
|
2011-07-18 06:22:39 +08:00
|
|
|
return self.name
|
|
|
|
|
2013-11-03 06:50:35 +08:00
|
|
|
|
2011-07-18 06:22:39 +08:00
|
|
|
class Feature(models.Model):
|
|
|
|
item = models.ForeignKey(SimpleItem)
|
2012-06-26 23:08:42 +08:00
|
|
|
|
2013-11-03 06:50:35 +08:00
|
|
|
|
2012-09-16 02:11:14 +08:00
|
|
|
class SpecialFeature(models.Model):
|
|
|
|
feature = models.ForeignKey(Feature)
|
|
|
|
|
2013-11-03 06:50:35 +08:00
|
|
|
|
2012-11-29 00:16:00 +08:00
|
|
|
class OneToOneItem(models.Model):
|
|
|
|
item = models.OneToOneField(Item, related_name="one_to_one_item")
|
|
|
|
name = models.CharField(max_length=15)
|
|
|
|
|
2013-11-03 06:50:35 +08:00
|
|
|
|
2012-06-26 23:08:42 +08:00
|
|
|
class ItemAndSimpleItem(models.Model):
|
|
|
|
item = models.ForeignKey(Item)
|
|
|
|
simple = models.ForeignKey(SimpleItem)
|
2013-05-30 13:16:09 +08:00
|
|
|
|
2013-11-03 06:50:35 +08:00
|
|
|
|
2013-05-30 13:16:09 +08:00
|
|
|
class Profile(models.Model):
|
2013-05-31 15:10:18 +08:00
|
|
|
profile1 = models.CharField(max_length=1000, default='profile1')
|
2013-05-30 13:16:09 +08:00
|
|
|
|
2013-11-03 06:50:35 +08:00
|
|
|
|
2013-05-30 13:16:09 +08:00
|
|
|
class Location(models.Model):
|
2013-05-31 15:10:18 +08:00
|
|
|
location1 = models.CharField(max_length=1000, default='location1')
|
2013-05-30 13:16:09 +08:00
|
|
|
|
2013-11-03 06:50:35 +08:00
|
|
|
|
2013-05-30 13:16:09 +08:00
|
|
|
class Request(models.Model):
|
|
|
|
profile = models.ForeignKey(Profile, null=True, blank=True)
|
|
|
|
location = models.ForeignKey(Location)
|
|
|
|
items = models.ManyToManyField(Item)
|
|
|
|
|
2013-05-31 15:10:18 +08:00
|
|
|
request1 = models.CharField(default='request1', max_length=1000)
|
|
|
|
request2 = models.CharField(default='request2', max_length=1000)
|
|
|
|
request3 = models.CharField(default='request3', max_length=1000)
|
|
|
|
request4 = models.CharField(default='request4', max_length=1000)
|