title: Generating lists/reports with in-line summaries in Django
body: <p>I am trying to write a view that will generate a report which displays all Items within my Inventory system, and provide summaries at a certain point. This report is purely just an HTML template by the way.</p>
  
  <p>In my case, each Item is part of an Order. An Order can have several items, and I want to be able to display SUM based summaries after the end of each order.</p>
  
  <p>So the report kind of looks like this:</p>
  
  <pre><code>Order #25        &lt;Qty&gt; &lt;Qty Sold&gt; &lt;Cost&gt; &lt;Cost Value&gt;
  Some Item          2       1       29.99    29.99
  Another Item       4       0       10.00    40.00
  &lt;Subtotal Line&gt;    6       1       39.99    69.99
  Order #26        &lt;Qty&gt; &lt;Qty Sold&gt; &lt;Cost&gt; &lt;Cost Value&gt;
  ... Etc, you get the point
  </code></pre>
  
  <p>Now, I'm perfectly capable of displaying all the values and already have a report showing all the Items, but I have no idea how I can place Subtotals within the report like that without doing <strong>alot</strong> of queries. The Quantity, Qty Sold, and Cost fields are just part of the Item model, and Cost Value is just a simple model function.</p>
  
  <p>Any help would be appreciated. Thanks in advance :-)</p>