mirror of
https://github.com/django/django.git
synced 2025-10-27 15:46:10 +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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user