title: Fetch distinct receivers from message model while preserving order
body: <p>I'm trying to build a messaging app. Here's my model:</p>
  
  <pre><code>class Message(models.Model):
      sender = models.ForeignKey(User, related_name="sender")
      receiver = models.ForeignKey(User, related_name="receiver")
      msg_content = models.TextField()
      created_at = models.DateTimeField(auto_now_add=True)
  </code></pre>
  
  <p>This is what I tried in the view:</p>
  
  <pre><code>data = Message.objects.filter(Q(sender=request.user) | Q(receiver=request.user)).order_by('-created_at')
  </code></pre>
  
  <p>In the template:</p>
  
  <pre><code>{% for abc in data %}
      {{ abc.receiver }} &lt;br/&gt;
  {% endfor %}
  </code></pre>
  
  <p>Here I want to filter the distinct receivers and re-order them based upon the fact that to whom <code>request.user</code> sent new message recently (as we see on social media platforms). </p>
  
  <p>How can I do that?</p>