Hello guys! So, here is what I want to do. I have a model Staff, that has a foreign key to the User model. I also have a model Match that has a foreign key to the User model.
I want to select how much Matches every Staff has. I don't know how to do that, so far I only got it working for the User model. From Staff, it will not allow to annonate Match.
This is what is working right now
User.objects.annotate(ammount=Count("match")).filter(Q(ammount__gt=0)).order_by("ammount")
And this is what I wanted to do
Staff.objects.annotate(ammount=Count("match")).filter(Q(ammount__gt=0)).order_by("ammount")
And by the way, is there any way to filter the matches? I want to filter the matches by a certain column.
Thanks a lot in advance!