Django ORM version of SQL COUNT(DISTINCT <column>)
You can indeed use distinct and count together, as seen on this answer: https://stackoverflow.com/a/13145407/237091
In your case:
SELECT sender_id, COUNT(id), COUNT(DISTINCT recipient_id)FROM myapp_messagesGROUP BY sender_id;
would become:
Message.objects.values('sender').annotate( message_count=Count('sender'), recipient_count=Count('recipient', distinct=True))