]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/models/base.py
Fix in query cache
[osqa.git] / forum / models / base.py
index 47f71e0c4c6e857db7bc5e9def1d82d2f06de3b0..912c21ac768129ce66b8d955b5ee751e4869f3ea 100644 (file)
@@ -178,8 +178,13 @@ 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):