diff options
| author | Tim Graham <timograham@gmail.com> | 2018-01-29 10:12:58 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-01-29 11:11:43 -0500 |
| commit | e6f0e324e28bc7d0c125415de871466aa1f4b983 (patch) | |
| tree | 4c3683809889a257c881886180998a8f286a7f3f /docs/ref | |
| parent | c2b969e124f65d375aac969f253279085b6f7078 (diff) | |
Fixed #29081 -- Clarified comments in QuerySet.select_related() example.
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/models/querysets.txt | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index 10251efc72..c3395e9c9a 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -935,11 +935,13 @@ following models:: ... then a call to ``Book.objects.select_related('author__hometown').get(id=4)`` will cache the related ``Person`` *and* the related ``City``:: + # Hits the database with joins to the author and hometown tables. b = Book.objects.select_related('author__hometown').get(id=4) p = b.author # Doesn't hit the database. c = p.hometown # Doesn't hit the database. - b = Book.objects.get(id=4) # No select_related() in this example. + # Without select_related()... + b = Book.objects.get(id=4) # Hits the database. p = b.author # Hits the database. c = p.hometown # Hits the database. |
