+ @classmethod
+ def _generate_cache_key(cls, key, group=None):
+ if group is None:
+ group = cls.__name__
+
+ return '%s:%s:%s' % (settings.APP_URL, group, key)
+
+ def cache_key(self):
+ return self._generate_cache_key(self.id)
+
+ @classmethod
+ def infer_cache_key(cls, querydict):
+ try:
+ pk = [v for (k,v) in querydict.items() if k in ('pk', 'pk__exact', 'id', 'id__exact'
+ ) or k.endswith('_ptr__pk') or k.endswith('_ptr__id')][0]
+
+ return cls._generate_cache_key(pk)
+ except:
+ return None
+