          it's useful.
          """
          pass
  
      def _setup_aggregate_query(self):
          """
          Prepare the query for computing a result that contains aggregate annotations.
          """
          opts = self.model._meta
          if self.query.group_by is None:
 
</s> remove     def _setup_aggregate_query(self):
 </s> add     def _setup_aggregate_query(self, aggregates): </s> remove         super(ValuesQuerySet, self)._setup_aggregate_query()
 </s> add         if self.aggregate_names is not None:
            self.aggregate_names.extend(aggregates)
            self.query.set_aggregate_mask(self.aggregate_names)

        super(ValuesQuerySet, self)._setup_aggregate_query(aggregates) </s> remove             aggregate.lookup in self.aggregate_select.keys()):
 </s> add             aggregate.lookup in self.aggregates.keys()): </s> remove         # 1. Update references in "select" and "where".
 </s> add         # 1. Update references in "select" (normal columns plus aliases),
        # "group by", "where" and "having".
    def _setup_aggregate_query(self, aggregates):
          it's useful.
          """
          pass
  
    def _setup_aggregate_query(self, aggregates):
          """
          Prepare the query for computing a result that contains aggregate annotations.
          """
          opts = self.model._meta
          if self.query.group_by is None:
keep keep keep keep replace keep keep keep keep keep
 Fixed #10182 -- Corrected realiasing and the process of evaluating values() for queries with aggregate clauses. This means that aggregate queries can now be used as subqueries (such as in an __in clause). Thanks to omat for the report.

This involves a slight change to the interaction of annotate() and values() clauses that specify a list of columns. See the docs for details.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9888 bcc190cf-cafb-0310-a4f2-bffc1f526a37 
django/db/models/query.py