Ticket #11263: generic_relations_inheritance_order_test.diff
File generic_relations_inheritance_order_test.diff, 1.9 KB (added by , 15 years ago) |
---|
-
tests/regressiontests/generic_relations_regress/tests.py
1 1 from django.test import TestCase 2 2 from django.contrib.contenttypes.models import ContentType 3 from models import Link, Place, Restaurant 3 from models import Link, Place, Restaurant, Visitor 4 4 5 5 class GenericRelationTests(TestCase): 6 6 … … 16 16 l2 = Link.objects.create(content_object=r) 17 17 self.assertEqual(list(p.links.all()), [l1]) 18 18 self.assertEqual(list(r.links.all()), [l2]) 19 20 No newline at end of file 19 20 def test_inherited_models_order(self): 21 """ 22 Test for "Bug in lookup with generic relation in model inheritance" 23 24 #11263 25 """ 26 Visitor.objects.filter(order__status='ordered').count() -
tests/regressiontests/generic_relations_regress/models.py
19 19 20 20 class Restaurant(Place): 21 21 def __unicode__(self): 22 return "Restaurant: %s" % self.name 23 No newline at end of file 22 return "Restaurant: %s" % self.name 23 24 # models for test_inherited_models_order (#11263) 25 class Order(models.Model): 26 content_type = models.ForeignKey(ContentType) 27 object_id = models.PositiveIntegerField() 28 content_object = generic.GenericForeignKey() 29 status = models.CharField(max_length=10, default='ordered') 30 31 class Person(models.Model): 32 pass 33 34 class Visitor(Person): 35 order = generic.GenericRelation(Order) 36