[Answer]-Django sort objects by number of friends who have them

1👍

you should be able to do:

(with user u)

users_objects = sorted(Ownership.objects.filter(user=u), key=lambda x:Ownership.objects.filter(item=x.item, user__in=u.friends).count())

Leave a comment