How does distinct parameter work with the Count method in annotate?
I got a problem with annotate method when I was using the Count method to count multiple columns that come from the database which have a relationship with one of the tables.
let me give you a quick example:
match_session_instance = MatchSessionInstance.objects.filter(match_session=match_session, status="main")
match_instances = MatchSessionInstance.objects.filter(match_session=match_session)
action_counts = match_instances.values(player_number=F("player_pk__number"), player_name=F("player_pk__player"))\
.annotate(pass_count=Count("live_match_pass__id", distinct=True),
corner_count=Count("live_match_corner__id", distinct=True))
in the meantime I'm not facing any problems I caught my issue and I addressed it but that is the problem now.
I don't know How could "disticnt=True" parameter helps me to fix that problem!
I googled a bit and found this source that has helped me: Count on multiple fields in Django querysets
I know what does distinct as a method in ORM but actually, I get no idea how it works in that format special when I used columns that never have duplicated data.
Can anyone help me to understand, please?
thanks in advance