title: How to go from a values_list to a dictionary of lists
body: <p>I have a django queryset that returns a list of values: </p>
  
  <pre><code>[(client pk, timestamp, value, task pk), (client pk, timestamp, value, task pk),....,].
  </code></pre>
  
  <p>I am trying to get it to return a dictionary of this format:</p>
  
  <pre><code>{client pk:[[timestamp, value],[timestamp, value],...,], client pk:[list of lists],...,}
  </code></pre>
  
  <p>The values_list may have multiple records for each client pk.  I have been able to get dictionaries of lists for client or task pk using:</p>
  
  <pre><code>def dict_from_vl(vls_list):
      keys=[values_list[x][3] for x in range(0,len(values_list),1)]
      values = [[values_list[x][1], values_list[x][2]] for x in range(0,len(values_list),1)]
      target_dict=dict(zip(keys,values))
      return target_dict
  </code></pre>
  
  <p>However using this method, values for the same key write over previous values as it iterates through the values_list, rather than append them to a list.  So this works great for getting the most recent if the values list is sorted oldest records to newest, but not for the purpose of creating a list of lists for the dict value.</p>