diff --git a/tests/modeltests/or_lookups/models.py b/tests/modeltests/or_lookups/models.py
index cd01447..be5117d 100644
a
|
b
|
|
1 | 1 | """ |
2 | 2 | 19. OR lookups |
3 | 3 | |
4 | | To perform an OR lookup, or a lookup that combines ANDs and ORs, |
| 4 | To perform an OR lookup, or a lookup that combines ANDs and ORs, |
5 | 5 | combine QuerySet objects using & and | operators. |
6 | 6 | |
7 | | Alternatively, use positional arguments, and pass one or more expressions |
| 7 | Alternatively, use positional arguments, and pass one or more expressions |
8 | 8 | of clauses using the variable ``django.db.models.Q`` (or any object with |
9 | 9 | a get_sql method). |
10 | 10 | |
… |
… |
API_TESTS = """
|
38 | 38 | >>> Article.objects.filter(headline__startswith='Hello') | Article.objects.filter(headline__startswith='Goodbye') |
39 | 39 | [Hello, Goodbye, Hello and goodbye] |
40 | 40 | |
| 41 | >>> Article.objects.filter(headline__startswith='Hello').union(Article.objects.filter(headline__startswith='Goodbye')) |
| 42 | [Hello, Goodbye, Hello and goodbye] |
| 43 | |
41 | 44 | >>> Article.objects.filter(Q(headline__startswith='Hello') | Q(headline__startswith='Goodbye')) |
42 | 45 | [Hello, Goodbye, Hello and goodbye] |
43 | 46 | |
… |
… |
API_TESTS = """
|
45 | 48 | [] |
46 | 49 | |
47 | 50 | >>> Article.objects.filter(headline__startswith='Hello') & Article.objects.filter(headline__startswith='Goodbye') |
| 51 | [] |
| 52 | |
| 53 | >>> Article.objects.filter(headline__startswith='Hello').intersection(Article.objects.filter(headline__startswith='Goodbye')) |
48 | 54 | [] |
49 | 55 | |
50 | 56 | >>> Article.objects.filter(headline__startswith='Hello') & Article.objects.filter(headline__contains='bye') |
… |
… |
API_TESTS = """
|
65 | 71 | >>> Article.objects.filter(Q(pk=1) | Q(pk=2) | Q(pk=3)) |
66 | 72 | [Hello, Goodbye, Hello and goodbye] |
67 | 73 | |
68 | | # Q arg objects are ANDed |
| 74 | # Q arg objects are ANDed |
69 | 75 | >>> Article.objects.filter(Q(headline__startswith='Hello'), Q(headline__contains='bye')) |
70 | 76 | [Hello and goodbye] |
71 | 77 | |
… |
… |
Hello and goodbye
|
86 | 92 | >>> Article.objects.filter(Q(headline__startswith='Hello')).in_bulk([1,2]) |
87 | 93 | {1: Hello} |
88 | 94 | |
89 | | # The 'complex_filter' method supports framework features such as |
| 95 | # The 'complex_filter' method supports framework features such as |
90 | 96 | # 'limit_choices_to' which normally take a single dictionary of lookup arguments |
91 | 97 | # but need to support arbitrary queries via Q objects too. |
92 | 98 | >>> Article.objects.complex_filter({'pk': 1}) |