def get_sum(qs, field):
    """
    get sum for queryset.

    ``qs``: queryset
    ``field``: The field name to sum.
    """
    sum_field = '%s__sum' % field
    qty = qs.aggregate(Sum(field))[sum_field]
    return qty if qty else 0