Commits

Nickolas Grigoriadis committed 8a9d64a

Queryset tuning.
Previously the function would generate 2 distinctly different querysets when getting a random cover image. This forces it to only do so once.

Comments (0)

Files changed (1)

             return self.cover
         elif getattr(self, '_cover', None):
             return self._cover
-        elif self.pictures.public():
-            self._cover = self.pictures.public().order_by('?')[0]
+        try:
+            _cov = self.pictures.public().order_by('?')[0]
+            self._cover = _cov
             return self._cover
-        else:
+        except IndexError:
             return None
 
     @property