def do_boolean_sum(field):
 cond = {field: True}
 return Sum(Case(When(then=1, **cond), default=0, output_field=IntegerField()))

def do_boolean_sum ( field ) : cond = { field : True } return Sum ( Case ( When ( then = 1 , ** cond ) , default = 0 , output_field = IntegerField ( ) ) )
wrapper to generate sum on boolean values .