mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #31943 -- Fixed recreating QuerySet.values()/values_list() when using a pickled Query.
This commit is contained in:
parent
84609b3205
commit
5362e08624
3 changed files with 39 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue