Sfoglia il codice sorgente

Fixed #29081 -- Clarified comments in QuerySet.select_related() example.

Tim Graham 7 anni fa
parent
commit
e6f0e324e2
1 ha cambiato i file con 3 aggiunte e 1 eliminazioni
  1. 3 1
      docs/ref/models/querysets.txt

+ 3 - 1
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.