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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -