﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
7813	Problem Pickling Querysets	Ed Menendez <ed@…>	Malcolm Tredinnick	"I saw a previously closed [http://code.djangoproject.com/ticket/7506 ticket 7506] for a related (no pun intended) problem. It seems like when we use select_related suddenly the queryset can't be pickled. This used to work back in May sometime. Currently using SVN 7944.

The models is attached.

{{{
# This works
ld = LeagueDivision.objects.all()
cache.set('test2', ld)

# This doesn't work
ld = LeagueDivision.objects.select_related('league_conference').all()
cache.set('test2', ld)
}}}

Traceback (most recent call last):
  File ""<console>"", line 1, in <module>
  File ""C:\Python25\lib\site-packages\django\core\cache\backends
\memcached.py"", line 35, in set
    self._cache.set(smart_str(key), value, timeout or
self.default_timeout)
  File ""C:\Projects\pyapps\memcache.py"", line 437, in set
    return self._set(""set"", key, val, time, min_compress_len)
  File ""C:\Projects\pyapps\memcache.py"", line 609, in _set
    store_info = self._val_to_store_info(val, min_compress_len, key)
  File ""C:\Projects\pyapps\memcache.py"", line 581, in
_val_to_store_info
    pickler.dump(val)
  File ""C:\Python25\lib\copy_reg.py"", line 71, in _reduce_ex
    raise TypeError, ""can't pickle %s objects"" % base.__name__
TypeError: can't pickle function objects

The dev environment is Windows, Python 2.5.1 using runserver built in web server with memcache (also on Windows) and Postgres 8.2 on Windows.

- Ed "		closed	Database layer (models, ORM)	dev		fixed	queryset pickle select_related	7944	Accepted	1	0	1	1	0	0
