Skip to content

Commit

Permalink
Updated 'or_lookup' tests to give example of more compact syntax, for…
Browse files Browse the repository at this point in the history
… the sake of autogenerated docs.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2897 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
spookylukey committed May 11, 2006
1 parent edce412 commit 4116403
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tests/modeltests/or_lookups/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ def __repr__(self):
>>> Article.objects.filter(Q(headline__startswith='Hello') & Q(headline__startswith='Goodbye'))
[]
>>> Article.objects.filter(headline__startswith='Hello') & Article.objects.filter(headline__startswith='Goodbye')
# You can shorten this syntax with code like the following,
# which is especially useful if building the query in stages:
>>> articles = Article.objects.all()
>>> articles.filter(headline__startswith='Hello') & articles.filter(headline__startswith='Goodbye')
[]
>>> Article.objects.filter(headline__startswith='Hello') & Article.objects.filter(headline__contains='bye')
>>> articles.filter(headline__startswith='Hello') & articles.filter(headline__contains='bye')
[Hello and goodbye]
>>> Article.objects.filter(Q(headline__contains='bye'), headline__startswith='Hello')
Expand Down

0 comments on commit 4116403

Please sign in to comment.