title: How to get unique values in queryset?
body: <p>I have following record in messages table:</p>
  <p><a href="https://i.stack.imgur.com/gxb0i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gxb0i.png" alt="data" /></a></p>
  <p>I want to get all the <strong>receiver</strong> where the <strong>sender</strong> is 15 and all the <strong>sender</strong> where the <strong>receiver</strong> is 15.</p>
  <p>I used this query:</p>
  <pre><code>class ContactListAPI(GenericAPIView, ListModelMixin ):
      def get_queryset(self):
          return Messages.objects.filter(Q(sender=15) | Q(receiver=15))
      serializer_class = ContactsSerializer
      permission_classes = (AllowAny,)
  
      def get(self, request , *args, **kwargs):
          return self.list(request, *args, **kwargs)
  </code></pre>
  <p>but it returns duplicates results also as follows:</p>
  <p><a href="https://i.stack.imgur.com/J0ckc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J0ckc.png" alt="result" /></a></p>
  <p>How can I get only the distinct/unique records.</p>
  <p>For example <code>{ sender: 15, receiver: 11 }</code> should not be repeated</p>
  <p>I also tried</p>
  <pre><code>Messages.objects.filter(sender=15).values_list('receiver', flat=True).union(
      Messages.objects.filter(receiver=15).values_list('sender', flat=True)
  )
  </code></pre>
  <p>but this is returning an empty array</p>