+ def get(self, *args, **kwargs):
+ try:
+ pk = [v for (k,v) in kwargs.items() if k in ('pk', 'pk__exact', 'id', 'id__exact'
+ ) or k.endswith('_ptr__pk') or k.endswith('_ptr__id')][0]
+ except:
+ pk = None
+
+ if pk is not None:
+ key = self.model.cache_key(pk)
+ obj = cache.get(key)
+
+ if obj is None:
+ obj = super(CachedQuerySet, self).get(*args, **kwargs)
+ obj.__class__.objects.cache_obj(obj)
+ else:
+ d = obj.__dict__
+
+ return obj
+
+ return super(CachedQuerySet, self).get(*args, **kwargs)
+