aboutsummaryrefslogtreecommitdiff
path: root/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'models.py')
-rw-r--r--models.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/models.py b/models.py
index 14270cf..40406e3 100644
--- a/models.py
+++ b/models.py
@@ -16,7 +16,7 @@
from functools import reduce
from django.db import models
-from django.db.models import Count, Manager, Q, Subquery
+from django.db.models import Count, Manager, Q, Subquery, Value
from django.db.models.expressions import OuterRef
from django.db.models.functions import ExtractWeek, ExtractYear
from django.utils import timezone
@@ -86,7 +86,8 @@ class GroupManager(Manager):
sub = self.get_queryset().filter(timetable=timetable,
mention__startswith=OuterRef("mention"),
subgroup__startswith=OuterRef("subgroup")) \
- .order_by().values("mention").annotate(c=Count("*")).values("c")
+ .annotate(v=Value(0)).values("v") \
+ .annotate(c=Count("v")).values("c") # fuck Count()
return self.get_queryset().filter(*args, timetable=timetable, hidden=False, **criteria) \
.annotate(nbsub=Subquery(sub, output_field=models.IntegerField())) \