All pastes #75895 Raw Edit

Unnamed

public python v1 · immutable
#75895 ·published 2006-06-30 18:31 UTC
rendered paste body
class ContribManager(models.Manager):    def affil_totals(self):        from django.db import connection        cursor = connection.cursor()        cursor.execute("""            select dc_affiliation.id, dc_affiliation.name, sum(amount)            from dc_contrib, dc_affiliation            where dc_contrib.affil_id=dc_affiliation.id            group by 1, 2            order by 3 desc""")        result_list = []        for row in cursor.fetchall():            p = self.model(id=row[0], name=row[1])            p.total = row[2]            result_list.append(p)        return result_list