Ticket #12721: oddrel.diff
File oddrel.diff, 2.1 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, Person, Address 3 from models import Link, Place, Restaurant, Person, Address, CharLink, TextLink, OddRelation1, OddRelation2 4 4 5 5 class GenericRelationTests(TestCase): 6 6 … … 30 30 qs = Person.objects.filter(addresses__zipcode='80433') 31 31 self.assertEqual(1, qs.count()) 32 32 self.assertEqual('Chef', qs[0].name) 33 34 def test_charlink_delete(self): 35 oddrel = OddRelation1.objects.create(name='clink') 36 cl = CharLink.objects.create(content_object=oddrel) 37 oddrel.delete() 38 39 def test_textlink_delete(self): 40 oddrel = OddRelation2.objects.create(name='tlink') 41 tl = TextLink.objects.create(content_object=oddrel) 42 oddrel.delete() -
tests/regressiontests/generic_relations_regress/models.py
40 40 41 41 def __unicode__(self): 42 42 return self.name 43 44 class CharLink(models.Model): 45 content_type = models.ForeignKey(ContentType) 46 object_id = models.CharField(max_length=100) 47 content_object = generic.GenericForeignKey() 48 49 class TextLink(models.Model): 50 content_type = models.ForeignKey(ContentType) 51 object_id = models.TextField() 52 content_object = generic.GenericForeignKey() 53 54 class OddRelation1(models.Model): 55 name = models.CharField(max_length=100) 56 clinks = generic.GenericRelation(CharLink) 57 58 class OddRelation2(models.Model): 59 name = models.CharField(max_length=100) 60 tlinks = generic.GenericRelation(TextLink) 61