title: get ids group by range django
body: <p>I have:
  Model:</p>
  
  <pre><code>id = PrimaryKey()
  value = IntegerField()
  </code></pre>
  
  <p>I would like to get list of ids group by value range between <code>1-7</code> and <code>8-30</code> and <code>&gt;30</code>.<br>
  What would be the <strong>efficient</strong> way to do so?<br>
  Or shall I write query for each range like:</p>
  
  <pre><code>one= Model.objects.filter(value__gt=0,value__lte=7).values_list(id)
  two= Model.objects.filter(value__gt=7,value__lte=30).values_list(id)
  three= Model.objects.filter(value__gt=30).values_list(id)
  </code></pre>
  
  <p>...
  can I do so via <code>aggregate Count</code>? I want minimum database transactions.</p>
  
  <h1>Updated:</h1>
  
  <p>Actually am trying to get how many products are sold, If they expires soon, then weekly count  else monthly like:<br></p>
  
  <ul>
  <li>Milk expires in 3 days. How many milk packets were sold in past 3
  days<br></li>
  <li>Bread expires in 7 days. How many bread were sold in past 7 days.
  <br></li>
  </ul>
  
  <p>here <code>value</code> is <code>expires_in</code> i.e. in how many days a product expires in <br>
  <code>(expiry date - mfg date)</code><br>
  <br>
  Model is like:<br></p>
  
  <p><strong>InvoiceBreakup</strong></p>
  
  <pre><code>product_id
  name
  desctiption
  expires_in
  </code></pre>