title: Django distinct group by query on two fields
body: <p>I have a model which have 2 fields.</p>
  
  <pre><code>class MyModel:
     tcode = Charfield
     created_on = Date field
     #some more fields
  </code></pre>
  
  <p>now this model can have multiple rows with same tcode, and each row can have different day or same.</p>
  
  <p>e.g.</p>
  
  <pre><code>tcode1, 1/2/2001
  tcode2, 1/2/2001
  tcode2, 2/2/2001
  ....etc.
  </code></pre>
  
  <p>I want to filter query on this model such that tcode and date field combination should be unique. how can I get all those objects. </p>
  
  <p>i was trying to do this</p>
  
  <p><code>MyModel.objects.all().order_by('tcode').distinct('tcode', 'created_on')</code></p>
  
  <p>Now you may ask that in case if there are two rows with same data in two fields which one row I want! it doesn't matter to me, any row would work fine.</p>