summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2020-09-10 14:34:04 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-09-11 07:58:52 +0200
commit5362e08624c6745181944a10979da876934ea136 (patch)
tree0e30705c0f6d199986567f0223ffa8928b4d3776 /docs
parent84609b3205905097d7d3038d32e6101f012c0619 (diff)
Fixed #31943 -- Fixed recreating QuerySet.values()/values_list() when using a pickled Query.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/querysets.txt14
1 files changed, 14 insertions, 0 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index 228e2cf736..7f55684e08 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -106,6 +106,20 @@ the query construction and is not part of the public API. However, it is safe
(and fully supported) to pickle and unpickle the attribute's contents as
described here.
+.. admonition:: Restrictions on ``QuerySet.values_list()``
+
+ If you recreate :meth:`QuerySet.values_list` using the pickled ``query``
+ attribute, it will be converted to :meth:`QuerySet.values`::
+
+ >>> import pickle
+ >>> qs = Blog.objects.values_list('id', 'name')
+ >>> qs
+ <QuerySet [(1, 'Beatles Blog')]>
+ >>> reloaded_qs = Blog.objects.all()
+ >>> reloaded_qs.query = pickle.loads(pickle.dumps(qs.query))
+ >>> reloaded_qs
+ <QuerySet [{'id': 1, 'name': 'Beatles Blog'}]>
+
.. admonition:: You can't share pickles between versions
Pickles of ``QuerySets`` are only valid for the version of Django that