diff options
| author | Tim Graham <timograham@gmail.com> | 2018-01-29 10:12:58 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-01-29 12:37:05 -0500 |
| commit | bbc4a5a792c4987eb143d1a9f09fd939f4609481 (patch) | |
| tree | c6d39d497941315186079cc014167dc7e94849f4 | |
| parent | c2962d8147380b00bb965c0d42b7e05ca4596868 (diff) | |
[2.0.x] Fixed #29081 -- Clarified comments in QuerySet.select_related() example.
Backport of e6f0e324e28bc7d0c125415de871466aa1f4b983 from master
| -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 5f5f73c830..8e4b7df216 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -941,11 +941,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. |
