]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/models/base.py
Merge cacheimp -> master
[osqa.git] / forum / models / base.py
index bf132c4e1bca3177cfe666ade6f95742c0bfe5a0..260910635c2291afaa5a16a83d14048670034d34 100644 (file)
@@ -150,6 +150,7 @@ class CachedQuerySet(models.query.QuerySet):
                 to_return = [(isinstance(tr, ToFetch) and fetched[str(tr)] or tr) for tr in to_return]
                 to_cache.update(dict([(self.model.infer_cache_key({on_cache_query_attr: attr}), r._as_dict()) for attr, r in fetched.items()]))
 
+
         if len(to_cache):
             cache.set_many(to_cache, 60 * 60)
 
@@ -257,6 +258,9 @@ class BaseModel(models.Model):
     def save(self, full_save=False, *args, **kwargs):
         put_back = [k for k, v in self.__dict__.items() if isinstance(v, models.expressions.ExpressionNode)]
 
+        if hasattr(self, '_state'):
+            self._state.db = 'default'
+
         if self.id and not full_save:
             self.__class__.objects.filter(id=self.id).update(**self._get_update_kwargs())
         else: