I saw a previously closed 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.
Here's the model:
class LeagueSeason(models.Model):
is_conference_used = models.BooleanField(default=False)
is_division_used = models.BooleanField(default=False)
class LeagueConference(models.Model):
league_season = models.ForeignKey(LeagueSeason)
name = models.CharField(max_length=50)
# slug is not unique by itself.
slug = models.CharField(max_length=50,
prepopulate_from=('name',), db_index=True)
sort_order = models.SmallIntegerField(default=1)
class LeagueDivision(models.Model):
league_conference = models.ForeignKey(LeagueConference)
name = models.CharField(max_length=50)
# slug is not unique by itself.
slug = models.CharField(max_length=50,
prepopulate_from=('name',), db_index=True)
sort_order = models.SmallIntegerField(default=1)
# 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
Is this supposed to be supported? Did we just get lucky when it used
to work in a previous version? Let me know if you need more info!
- Ed
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---