[Answer]-How to select users which is not paired with a custom user through many-to-one?

1👍

Make a list of ids you don’t want:

excluded_ids = [user.id for user in MarkedUserIds.objects.filter(marked_user_id = {specific_one_user_id})]

Then get Users excluding those ids:

WaitingUser.objects.exclude(user_id__in = excluded_ids)

EDIT:
In one query:

WaitingUser.objects.exclude(id__in = MarkedUserIds.objects.filter(marked_user_id = {specific_one_user_id}).values_list('id', flat=True))

I may not be understanding your filter conditions correctly.

Hope it helps.

👤McAbra

Leave a comment