Skip to content

Commit cd3370c

Browse files
committed
[1.1.X] Fixed #13263 -- Corrected field name typo in queries documentation examples. Thanks, RicherPots for bug report and gabrielhurley for the patch.
Backport of r12926 from trunk git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12927 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent b262752 commit cd3370c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/topics/db/queries.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -419,22 +419,22 @@ models doesn't have a value that meets the filter condition, Django will treat
419419
it as if there is an empty (all values are ``NULL``), but valid, object there.
420420
All this means is that no error will be raised. For example, in this filter::
421421

422-
Blog.objects.filter(entry__author__name='Lennon')
422+
Blog.objects.filter(entry__authors__name='Lennon')
423423

424424
(if there was a related ``Author`` model), if there was no ``author``
425425
associated with an entry, it would be treated as if there was also no ``name``
426426
attached, rather than raising an error because of the missing ``author``.
427427
Usually this is exactly what you want to have happen. The only case where it
428428
might be confusing is if you are using ``isnull``. Thus::
429429

430-
Blog.objects.filter(entry__author__name__isnull=True)
430+
Blog.objects.filter(entry__authors__name__isnull=True)
431431

432432
will return ``Blog`` objects that have an empty ``name`` on the ``author`` and
433433
also those which have an empty ``author`` on the ``entry``. If you don't want
434434
those latter objects, you could write::
435435

436-
Blog.objects.filter(entry__author__isnull=False,
437-
entry__author__name__isnull=True)
436+
Blog.objects.filter(entry__authors__isnull=False,
437+
entry__authors__name__isnull=True)
438438

439439
Spanning multi-valued relationships
440440
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -532,7 +532,7 @@ any joins needed to access the related object. For example, to retrieve all
532532
the entries where the author's name is the same as the blog name, we could
533533
issue the query:
534534

535-
>>> Entry.objects.filter(author__name=F('blog__name'))
535+
>>> Entry.objects.filter(authors__name=F('blog__name'))
536536

537537
The pk lookup shortcut
538538
----------------------

0 commit comments

Comments
 (0)