Fix views & update templates

This commit is contained in:
Nyymix 2025-04-11 22:38:20 +03:00
parent 3029eea1a0
commit bd12a0abef
5 changed files with 24 additions and 6 deletions

View file

@ -3,6 +3,7 @@ from math import floor
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models import Sum
from django.templatetags.static import static
from django.urls import reverse
from django.utils.text import slugify
@ -24,8 +25,8 @@ class Album(models.Model):
@property
def photos_views(self):
total_views = sum(self.photos.views())
return total_views
return self.photos.aggregate(total_views=Sum('views'))['total_views'] or 0
@property
def cover_image_data(self):