Aggregate totals of a ViewSet results in Django Rest Framework
<p>I have a ViewSet which outputs a set of results:</p>

<pre><code>{
    "count": 19355,
    "next": null,
    "previous": null,
    "results": [
        {
            "duration": 5,
            ...
        },
        {
            "duration": 5,
            ...
        },
        ...
    ]
}
</code></pre>

<p>I would like to aggregate the totals of the duration of the results, right in that handy little top area next to "count". I know how to do this in a queryset, using annotate and sum, but I don't see a way to get it into the ViewSet output.</p>

<p>Desired output for this data set would be:</p>

<pre><code>{
    "count": 19355,
    "total_duration": 10,
    "next": null,
    "previous": null,
    "results": [
        {
            "duration": 5,
            ...
        },
        {
            "duration": 5,
            ...
        },
        ...
    ]
}
</code></pre>

<p>I appreciate the help!</p>