Django condition aggregation, count when entry exists -
what want this:
foo.objects.all().annotate(c=count(case(when(bar_set= exists,then 1)))) that is, count cases bar_set not empty.
# should not counted foo.bar_set() >>> [] # should counted foo.bar_set() >>> [<bar: bar object>] how can done?
Comments
Post a Comment