diff -r 23ee026c45ef tests/regressiontests/generic_relations_regress/models.py
a
|
b
|
|
2 | 2 | from django.contrib.contenttypes import generic |
3 | 3 | from django.contrib.contenttypes.models import ContentType |
4 | 4 | |
5 | | __all__ = ('Link', 'Place', 'Restaurant', 'Person', 'Address', |
6 | | 'CharLink', 'TextLink', 'OddRelation1', 'OddRelation2', |
| 5 | __all__ = ('Link', 'Place', 'Restaurant', 'Person', 'Address', |
| 6 | 'CharLink', 'TextLink', 'OddRelation1', 'OddRelation2', |
7 | 7 | 'Contact', 'Organization', 'Note') |
8 | 8 | |
9 | 9 | class Link(models.Model): |
… |
… |
|
46 | 46 | return self.name |
47 | 47 | |
48 | 48 | class CharLink(models.Model): |
| 49 | title = models.CharField(max_length=20) |
49 | 50 | content_type = models.ForeignKey(ContentType) |
50 | 51 | object_id = models.CharField(max_length=100) |
51 | 52 | content_object = generic.GenericForeignKey() |
52 | 53 | |
53 | 54 | class TextLink(models.Model): |
| 55 | title = models.CharField(max_length=20) |
54 | 56 | content_type = models.ForeignKey(ContentType) |
55 | 57 | object_id = models.TextField() |
56 | 58 | content_object = generic.GenericForeignKey() |
diff -r 23ee026c45ef tests/regressiontests/generic_relations_regress/tests.py
a
|
b
|
|
42 | 42 | tl = TextLink.objects.create(content_object=oddrel) |
43 | 43 | oddrel.delete() |
44 | 44 | |
| 45 | def test_charlink_filter(self): |
| 46 | # Regression for #16055 |
| 47 | oddrel = OddRelation1.objects.create(name='clink') |
| 48 | cl = CharLink.objects.create(content_object=oddrel, title='title') |
| 49 | OddRelation1.objects.filter(clinks__title='title') |
| 50 | |
| 51 | def test_textlink_filter(self): |
| 52 | # Regression for #16055 |
| 53 | oddrel = OddRelation2.objects.create(name='tlink') |
| 54 | tl = TextLink.objects.create(content_object=oddrel, title='title') |
| 55 | OddRelation2.objects.filter(tlinks__title='title') |
| 56 | |
45 | 57 | def test_q_object_or(self): |
46 | 58 | """ |
47 | 59 | Tests that SQL query parameters for generic relations are properly |