Django: Post-QSRF Aggregation

I’m in the process of upgrading critify to the current SVN trunk, with QSRF now included. So far, everything is going smoothly, and I believe I am about done.

At one point in the project I need to let the database do a SUM()/COUNT() calculation. Not wanting to write the complete SQL manually, I had previously used a patched Django version that allowed me to retrieve the query generated by a QuerySet before it’s execution, replace the select clause, then send it through connection.execute().

Fortunately, with the new and improved QuerySet implementation, that’s a thing of the past now (and not only because you can now access the generated SQL via QuerySet.query.as_sql()!). While official aggregation support is still being worked on, the groundwork seems already in place: