diff options
| author | Luke Plant <L.Plant.98@cantab.net> | 2006-05-11 21:51:24 +0000 |
|---|---|---|
| committer | Luke Plant <L.Plant.98@cantab.net> | 2006-05-11 21:51:24 +0000 |
| commit | 4116403a55fd816220703a8ae9f3ed592131ba5a (patch) | |
| tree | df01c2007ed69943f80877f48817b62f0272764e /tests/modeltests | |
| parent | edce4128e14042c28886bb9ab12d92bf83c5b704 (diff) | |
Updated 'or_lookup' tests to give example of more compact syntax, for the sake of autogenerated docs.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@2897 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/modeltests')
| -rw-r--r-- | tests/modeltests/or_lookups/models.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/modeltests/or_lookups/models.py b/tests/modeltests/or_lookups/models.py index cd01447a35..a07dacdd5a 100644 --- a/tests/modeltests/or_lookups/models.py +++ b/tests/modeltests/or_lookups/models.py @@ -44,10 +44,13 @@ API_TESTS = """ >>> 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') |
