mirror of
https://github.com/django/django.git
synced 2025-12-02 00:01:29 +00:00
Fixed #10197 -- Corrected pickling of querysets when a subset of fields was selected.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10522 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
0fff47c90f
commit
e12e0e18a4
2 changed files with 21 additions and 0 deletions
|
|
@ -123,12 +123,18 @@ class BaseQuery(object):
|
|||
obj_dict['related_select_fields'] = []
|
||||
obj_dict['related_select_cols'] = []
|
||||
del obj_dict['connection']
|
||||
|
||||
# Fields can't be pickled, so we pickle the list of field names instead.
|
||||
obj_dict['select_fields'] = [f.name for f in obj_dict['select_fields']]
|
||||
return obj_dict
|
||||
|
||||
def __setstate__(self, obj_dict):
|
||||
"""
|
||||
Unpickling support.
|
||||
"""
|
||||
# Rebuild list of field instances
|
||||
obj_dict['select_fields'] = [obj_dict['model']._meta.get_field(name) for name in obj_dict['select_fields']]
|
||||
|
||||
self.__dict__.update(obj_dict)
|
||||
# XXX: Need a better solution for this when multi-db stuff is
|
||||
# supported. It's the only class-reference to the module-level
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue