X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/3d331ce2c042eb92ae71c3875e30ddd76e8db7e3..dcacc3b4c2ba2f550806a2d22b183f6fac4f63ff:/forum/models/base.py diff --git a/forum/models/base.py b/forum/models/base.py index 47f71e0..9c328c5 100644 --- a/forum/models/base.py +++ b/forum/models/base.py @@ -178,14 +178,19 @@ class CachedQuerySet(models.query.QuerySet): yield row def _get_query_hash(self): - return md5(unicode(self.query).encode("utf-8")).hexdigest() - + try: + return md5(unicode(self.query).encode("utf-8")).hexdigest() + except: + try: + return md5(self.query).hexdigest() + except: + return md5(str(self.query)).hexdigest() class CachedManager(models.Manager): use_for_related_fields = True - def get_query_set(self): + def get_queryset(self): return CachedQuerySet(self.model) def get_or_create(self, *args, **kwargs): @@ -221,7 +226,7 @@ class DenormalizedField(object): cls.add_to_class("reset_%s_cache" % name, reset_cache) -class BaseMetaClass(models.Model.__metaclass__): +class BaseMetaClass(type(models.Model)): to_denormalize = [] def __new__(cls, *args, **kwargs):