在Django模型中将NULL视为’0′

from django.db.models.functions import Coalesce

score = self.picturevote_set.aggregate(Coalesce(models.Sum(‘value’), 0))

Leave a Comment

Your email address will not be published. Required fields are marked *