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

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

Ansible warning on jinja2 braces on when -

html - How to custom Bootstrap grid height? -