Skip to content

Commit 614dd44

Browse files
koniiiiktimgraham
authored andcommitted
[1.6.x] Fixed #23817 -- Updated docs on QuerySet evaluation
Removed inaccurate info about partial evaluation after refs django#18702. Added information on modifying sliced QuerySets; refs #22503. Backport of 327df55 from master
1 parent 2e7ca09 commit 614dd44

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/ref/models/querysets.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ You can evaluate a ``QuerySet`` in the following ways:
3939
``QuerySet`` usually returns another unevaluated ``QuerySet``, but Django
4040
will execute the database query if you use the "step" parameter of slice
4141
syntax, and will return a list. Slicing a ``QuerySet`` that has been
42-
evaluated (partially or fully) also returns a list.
42+
evaluated also returns a list.
43+
44+
Also note that even though slicing an unevaluated ``QuerySet`` returns
45+
another unevaluated ``QuerySet``, modifying it further (e.g., adding
46+
more filters, or modifying ordering) is not allowed, since that does not
47+
translate well into SQL and it would not have a clear meaning either.
4348

4449
* **Pickling/Caching.** See the following section for details of what
4550
is involved when `pickling QuerySets`_. The important thing for the
@@ -63,11 +68,6 @@ You can evaluate a ``QuerySet`` in the following ways:
6368

6469
entry_list = list(Entry.objects.all())
6570

66-
Be warned, though, that this could have a large memory overhead, because
67-
Django will load each element of the list into memory. In contrast,
68-
iterating over a ``QuerySet`` will take advantage of your database to
69-
load data and instantiate objects only as you need them.
70-
7171
* **bool().** Testing a ``QuerySet`` in a boolean context, such as using
7272
``bool()``, ``or``, ``and`` or an ``if`` statement, will cause the query
7373
to be executed. If there is at least one result, the ``QuerySet`` is

0 commit comments

Comments
 (0)