X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/a702df34f63291c9aa76a202824455d64fdd8bf9..49d0961a6f7f585f707cd08817f3e0a9f1a19212:/forum/models/base.py?ds=inline diff --git a/forum/models/base.py b/forum/models/base.py index fff741c..2f934a9 100644 --- a/forum/models/base.py +++ b/forum/models/base.py @@ -35,7 +35,7 @@ class LazyQueryList(object): class CachedQuerySet(models.query.QuerySet): def lazy(self): - if len(self.query.extra) == 0: + if (not len(self.query.extra)) and (not len(self.query.aggregates)): return LazyQueryList(self.model, list(self.values_list('id', flat=True))) else: return self @@ -151,10 +151,10 @@ class BaseModel(models.Model): (f.name, getattr(self, f.name)) for f in self._meta.fields if self._original_state[f.attname] != self.__dict__[f.attname] ]) - def save(self, *args, **kwargs): + 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 self.id: + if self.id and not full_save: self.__class__.objects.filter(id=self.id).update(**self._get_update_kwargs()) else: super(BaseModel, self).save()