2👍
✅
If I understood correctly, it is achievable using annotations. Since I am not aware of your models, it would look something like this:
PhotoSet.objects.values("id").annotate(Count("tags"))
Source:stackexchange.com