diff options
| author | Luke Plant <L.Plant.98@cantab.net> | 2010-08-28 11:30:28 +0000 |
|---|---|---|
| committer | Luke Plant <L.Plant.98@cantab.net> | 2010-08-28 11:30:28 +0000 |
| commit | be7f912ce75838aaa94c29967a334e443fa88aa0 (patch) | |
| tree | a31c46241ea2dbe5d47f37da97b0ac7c5433def2 /docs/ref | |
| parent | 37d5ec34b6032f1c64989b7b4b9581541273276a (diff) | |
[1.2.X] Fixed #14185 - improved example SQL for 'select' example.
Thanks to Trindaz for the suggestion.
Also fixed some references to 'lede' which is no longer part of the
example Blog model.
Backport of [13652] from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@13653 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/models/querysets.txt | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index a42452d07d..c1c586aada 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -703,9 +703,10 @@ of the arguments is required, but you should use at least one of them. greater than Jan. 1, 2006. Django inserts the given SQL snippet directly into the ``SELECT`` - statement, so the resulting SQL of the above example would be:: + statement, so the resulting SQL of the above example would be something + like:: - SELECT blog_entry.*, (pub_date > '2006-01-01') + SELECT blog_entry.*, (pub_date > '2006-01-01') AS is_recent FROM blog_entry; @@ -859,7 +860,7 @@ deferred field will be retrieved from the database if you access that field You can make multiple calls to ``defer()``. Each call adds new fields to the deferred set:: - # Defers both the body and lede fields. + # Defers both the body and headline fields. Entry.objects.defer("body").filter(rating=5).defer("headline") The order in which fields are added to the deferred set does not matter. Calling ``defer()`` with a field name that has already been deferred is harmless (the field will still be deferred). @@ -919,7 +920,7 @@ immediately; the remainder are deferred. Thus, successive calls to ``only()`` result in only the final fields being considered:: # This will defer all fields except the headline. - Entry.objects.only("body", "lede").only("headline") + Entry.objects.only("body", "rating").only("headline") Since ``defer()`` acts incrementally (adding fields to the deferred list), you can combine calls to ``only()`` and ``defer()`` and things will behave |
