Ticket #18595: ticket_18595_tests.diff

File ticket_18595_tests.diff, 1.2 KB (added by Anssi Kääriäinen, 12 years ago)
  • tests/modeltests/many_to_many/models.py

    diff --git a/tests/modeltests/many_to_many/models.py b/tests/modeltests/many_to_many/models.py
    index 5076e35..9e99f77 100644
    a b class Article(models.Model):  
    2828
    2929    class Meta:
    3030        ordering = ('headline',)
     31
     32
     33class Company( models.Model ):
     34    name = models.CharField(max_length=100)
     35    articles = models.ManyToManyField(Article, related_name='+')
     36
     37
     38class Location( models.Model ):
     39    company = models.ForeignKey(Company)
     40    address = models.CharField(max_length=100)
     41    articles = models.ManyToManyField(Article, related_name='+')
  • tests/modeltests/many_to_many/tests.py

    diff --git a/tests/modeltests/many_to_many/tests.py b/tests/modeltests/many_to_many/tests.py
    index 44bdde3..5815b47 100644
    a b class ManyToManyTests(TestCase):  
    387387        self.assertQuerysetEqual(self.a4.publications.all(), [])
    388388        self.assertQuerysetEqual(self.p2.article_set.all(),
    389389                                 ['<Article: NASA finds intelligent life on Earth>'])
     390
     391    def test_related_name(self):
     392        c = Company.objects.create(name='Foo')
     393        print c.articles.all().query
     394
Back to Top