diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2009-04-11 13:20:51 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2009-04-11 13:20:51 +0000 |
| commit | e12e0e18a4a666c22e119990a495c76079110934 (patch) | |
| tree | da76b4a8165ac29613a11f58ac98df0e3a776b6e /django/db/models | |
| parent | 0fff47c90f01c33ffdd0e8ed8c4a623693b7d4dd (diff) | |
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
Diffstat (limited to 'django/db/models')
| -rw-r--r-- | django/db/models/sql/query.py | 6 |
1 files changed, 6 insertions, 0 deletions
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 |
