I use the following bit of code in my Django app:
pictures = gallery.picture_set.annotate( score=models.Sum( \'picturevote__value\' ) ).order_by( \'-score\'
From Django 1.8, there is a Coalesce database function. Your query might look like this:
from django.db.models.functions import Coalesce score = self.picturevote_set.aggregate(Coalesce(models.Sum('value'), 0))