'Adds a single aggregate expression to the Query'

def add_aggregate(self, aggregate, model, alias, is_summary):

    opts = model._meta
    field_list = aggregate.lookup.split(LOOKUP_SEP)
    if ((len(field_list) == 1) and (aggregate.lookup in self.aggregates)):
        field_name = field_list[0]
        col = field_name
        source = self.aggregates[field_name]
        if (not is_summary):
            raise FieldError(("Cannot    compute    %s('%s'):    '%s'    is    an    aggregate" % (aggregate.name, field_name, field_name)))
    elif ((len(field_list) > 1) or (field_list[0] not in [i.name for i in opts.fields]) or (self.group_by is None) or (not is_summary)):
        (field, source, opts, join_list, last, _) = self.setup_joins(field_list, opts, self.get_initial_alias(), False)
        (col, _, join_list) = self.trim_joins(source, join_list, last, False)
        self.promote_joins(join_list, True)
        col = (join_list[(-1)], col)
    else:
        field_name = field_list[0]
        source = opts.get_field(field_name)
        col = field_name
    aggregate.add_to_query(self, alias, col=col, source=source, is_summary=is_summary)
