title: Django - Private messaging conversation view
body: <p>I have built a very basic private messaging module for my Django project.</p>
  
  <p>I have a Message model which consists of:</p>
  
  <pre><code>sender (Foreign key to the member model)
  recipient (Foreign key to the member model)
  message
  date (Datetime of which the message was created)
  </code></pre>
  
  <p>Now my issue is i would like to create a new view which returns a list of conversations based on these messages.</p>
  
  <p>I am trying to write a query which returns the latest messages but unique where sender = current user OR recipient = current user. This is so that i have a list of latest messages, which should be the equivalent of a conversation list. Have i got that bit right or am i completely over thinking things?</p>
  
  <pre><code>conversations = Message.objects.filter(Q(recipient=request.user) | 
  Q(sender=request.user)).annotate(max=Max('date'))
  </code></pre>
  
  <p>but this is returning duplicate conversations I tried this from another stack overflow post: </p>
  
  <pre><code>conversations = Message.objects.order_by('recipient', 'sender', 
  'date').distinct('recipient', 'sender') 
  </code></pre>
  
  <p>but I'm receiving this error "DISTINCT ON fields is not supported by this database backend"</p>
  
  <p>Any help would be greatly appreciated.</p>