[Answer]-How to convert this MySQL query to a Django query?

1👍

Try something like this:

files = File.objects.filter(users_id=request.user.id).annotate(count=Count('share__shared_user_id')

Then you should have

for f in files:
    print f.file_name, f.count
👤Mikael

Leave a comment