Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

django sum get 0 if none

answers = Answer.objects.filter(<something here>)
                        .annotate(score=Coalesce(Sum('vote__type'), 0))
                        .order_by('-score')
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #django #sum
ADD COMMENT
Topic
Name
8+7 =