Code

Ticket #18595: ticket_18595_tests.diff

File ticket_18595_tests.diff, 1.2 KB (added by akaariai, 21 months ago)
Line 
1diff --git a/tests/modeltests/many_to_many/models.py b/tests/modeltests/many_to_many/models.py
2index 5076e35..9e99f77 100644
3--- a/tests/modeltests/many_to_many/models.py
4+++ b/tests/modeltests/many_to_many/models.py
5@@ -28,3 +28,14 @@ class Article(models.Model):
6 
7     class Meta:
8         ordering = ('headline',)
9+
10+
11+class Company( models.Model ):
12+    name = models.CharField(max_length=100)
13+    articles = models.ManyToManyField(Article, related_name='+')
14+
15+
16+class Location( models.Model ):
17+    company = models.ForeignKey(Company)
18+    address = models.CharField(max_length=100)
19+    articles = models.ManyToManyField(Article, related_name='+')
20diff --git a/tests/modeltests/many_to_many/tests.py b/tests/modeltests/many_to_many/tests.py
21index 44bdde3..5815b47 100644
22--- a/tests/modeltests/many_to_many/tests.py
23+++ b/tests/modeltests/many_to_many/tests.py
24@@ -387,3 +387,8 @@ class ManyToManyTests(TestCase):
25         self.assertQuerysetEqual(self.a4.publications.all(), [])
26         self.assertQuerysetEqual(self.p2.article_set.all(),
27                                  ['<Article: NASA finds intelligent life on Earth>'])
28+
29+    def test_related_name(self):
30+        c = Company.objects.create(name='Foo')
31+        print c.articles.all().query
32+