]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/models/base.py
Fixed problem in data cache with international strings
[osqa.git] / forum / models / base.py
index 33bf0c8dfbb4afe54496fae6958a62d1b71b46a7..a5f74eb39821c17213094a40ff668e90240941fd 100644 (file)
@@ -83,7 +83,8 @@ class CachedQuerySet(models.query.QuerySet):
                 obj.cache()
             else:
                 obj = self.obj_from_datadict(obj)
-                obj.reset_original_state()
+
+            obj.reset_original_state()
 
             return obj
 
@@ -171,12 +172,16 @@ class CachedQuerySet(models.query.QuerySet):
         if to_return:
             for row in to_return:
                 if hasattr(row, 'leaf'):
-                    yield row.leaf
-                else:
-                    yield row
+                    row = row.leaf
+
+                row.reset_original_state()
+                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:
+            return md5(self.query).hexdigest()