diff options
Diffstat (limited to 'tests/modeltests/m2m_and_m2o/models.py')
-rw-r--r-- | tests/modeltests/m2m_and_m2o/models.py | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/tests/modeltests/m2m_and_m2o/models.py b/tests/modeltests/m2m_and_m2o/models.py index 0ab7a72d57..0fea1a2e7b 100644 --- a/tests/modeltests/m2m_and_m2o/models.py +++ b/tests/modeltests/m2m_and_m2o/models.py @@ -19,47 +19,3 @@ class Issue(models.Model): class Meta: ordering = ('num',) - - -__test__ = {'API_TESTS':""" ->>> Issue.objects.all() -[] ->>> r = User(username='russell') ->>> r.save() ->>> g = User(username='gustav') ->>> g.save() - ->>> i = Issue(num=1) ->>> i.client = r ->>> i.save() - ->>> i2 = Issue(num=2) ->>> i2.client = r ->>> i2.save() ->>> i2.cc.add(r) - ->>> i3 = Issue(num=3) ->>> i3.client = g ->>> i3.save() ->>> i3.cc.add(r) - ->>> from django.db.models.query import Q - ->>> Issue.objects.filter(client=r.id) -[<Issue: 1>, <Issue: 2>] ->>> Issue.objects.filter(client=g.id) -[<Issue: 3>] ->>> Issue.objects.filter(cc__id__exact=g.id) -[] ->>> Issue.objects.filter(cc__id__exact=r.id) -[<Issue: 2>, <Issue: 3>] - -# These queries combine results from the m2m and the m2o relationships. -# They're three ways of saying the same thing. ->>> Issue.objects.filter(Q(cc__id__exact=r.id) | Q(client=r.id)) -[<Issue: 1>, <Issue: 2>, <Issue: 3>] ->>> Issue.objects.filter(cc__id__exact=r.id) | Issue.objects.filter(client=r.id) -[<Issue: 1>, <Issue: 2>, <Issue: 3>] ->>> Issue.objects.filter(Q(client=r.id) | Q(cc__id__exact=r.id)) -[<Issue: 1>, <Issue: 2>, <Issue: 3>] -"""} |