[Answered ]-How to get distinct record from database query in django?

1👍

You can work with:

Messages.objects.filter(sender=15).values_list('receiver', flat=True).union(
    Messages.objects.filter(receiver=15).values_list('sender', flat=True)
)

Leave a comment