[Fixed]-Returning multiple fetched users

1👍

Instead of:

for freelancer in candidate_freelancers:
    freelancers = User.objects.filter(freelancer=freelancer.id)

try:

freelancers = User.objects.filter(freelancer__in=[freelancer.id for freelancer in candidate_freelancers])

out:

[<User: user1>, <User: user2>]

Leave a comment