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