Skip to content

Commit

Permalink
values_list returns a ValuesListQuerySet, you need to cast it to a li…
Browse files Browse the repository at this point in the history
…st in order for it to be pickled.
  • Loading branch information
baratrion authored and mmalone committed Dec 8, 2009
1 parent ef7dd47 commit c22a665
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions app/fields.py
Expand Up @@ -16,7 +16,7 @@ def wrap_add(f):
def add(self, *args, **kwargs):
"""
Wraps django.db.models.sql.where.add to indicate that a new
'where' condition has been added.
'where' condition has been added.
"""
self.modified = True
return f(*args, **kwargs)
Expand Down Expand Up @@ -50,7 +50,7 @@ def iterator(self):
superiter = super(PKListQuerySet, self).iterator()
while True:
yield superiter.next()

def _clone(self, *args, **kwargs):
c = super(PKListQuerySet, self)._clone(*args, **kwargs)
c.query.where = fix_where(c.query.where, modified=self.query.where.modified)
Expand All @@ -70,7 +70,7 @@ def all(self):
pk_list = cache.get(key)
if pk_list is None:
pk_list = qs.values_list('pk', flat=True)
cache.add(key, pk_list, CACHE_DURATION)
cache.add(key, list(pk_list), CACHE_DURATION)
else:
qs.from_cache = True
qs.pk_list = pk_list
Expand Down Expand Up @@ -101,9 +101,9 @@ class CachingReverseManyRelatedObjectsDescriptor(ReverseManyRelatedObjectsDescri
def __get__(self, instance, cls=None):
manager = super(CachingReverseManyRelatedObjectsDescriptor, self).__get__(instance, cls)

CachingRelatedManager = get_caching_related_manager(manager.__class__,
instance,
self.field.name,
CachingRelatedManager = get_caching_related_manager(manager.__class__,
instance,
self.field.name,
self.field.rel.related_name)

manager.__class__ = CachingRelatedManager
Expand Down Expand Up @@ -131,3 +131,4 @@ def contribute_to_class(self, cls, name):
def contribute_to_related_class(self, cls, related):
super(CachingManyToManyField, self).contribute_to_related_class(cls, related)
setattr(cls, related.get_accessor_name(), CachingManyRelatedObjectsDescriptor(related))

0 comments on commit c22a665

Please sign in to comment.