You can use the Coalesce function from django.db.models.functions like:
answers = (Answer.objects
.filter(<something here>)
.annotate(score=Coalesce(Sum('vote__type'), 0))
.order_by('-score'))
You can use the Coalesce function from django.db.models.functions like:
answers = (Answer.objects
.filter(<something here>)
.annotate(score=Coalesce(Sum('vote__type'), 0))
.order_by('-score'))