from django.db import connection
with connection.cursor() as c:
    c.execute(
        'select year(joined_date) year, month(joined_date) month, count(*) total '
        'from c4_user_sys_account group by year, month order by year, month')
    fetchall = c.fetchall()

    items = []
    for row in fetchall:
        item = {}
        item["year"] = row[0]
        item["month"] = row[1]
        item["total"] = row[2]
        items.append(item)

[ 编辑 | 历史 ]
最近由“jilili”在“2017-04-23 04:27:26”修改