From e12e0e18a4a666c22e119990a495c76079110934 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Sat, 11 Apr 2009 13:20:51 +0000 Subject: 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 --- django/db/models/sql/query.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'django/db/models/sql/query.py') diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 403968e118..df4de2a750 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -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 -- cgit v1.3