Ticket #1535: pythonconsole.txt

File pythonconsole.txt, 882 bytes (added by Russell Cloran <russell@…>, 9 years ago)

My test session output

Line 
1>>> from test.models import Issue
2>>> Issue.objects.all()
3[]
4>>> from django.contrib.auth.models import User
5>>> r = User.objects.get(username='russell')
6>>> g = User.objects.get(username='gustav')
7>>> i = Issue()
8>>> i.client = r
9>>> i.validate()
10{}
11>>> i.save()
12>>> i2 = Issue()
13>>> i2.client = r
14>>> i2.validate()
15{}
16>>> i2.save()
17>>> i2.cc.add(r)
18>>> i3 = Issue()
19>>> i3.client = g
20>>> i3.validate()
21{}
22>>> i3.save()
23>>> i3.cc.add(r)
24>>> from django.db.models.query import Q
25>>> Issue.objects.filter(client=r.id)
26[<Issue 3>, <Issue 4>]
27>>> Issue.objects.filter(client=g.id)
28[<Issue 5>]
29>>> Issue.objects.filter(cc__id__exact=g.id)
30[]
31>>> Issue.objects.filter(cc__id__exact=r.id)
32[<Issue 4>, <Issue 5>]
33>>> Issue.objects.filter(Q(cc__id__exact=r.id) | Q(client=r.id))
34[<Issue 4>, <Issue 5>]
35>>> Issue.objects.filter(Q(client=r.id) | Q(cc__id__exact=r.id))
36[<Issue 4>, <Issue 5>]
Back to Top