[Django]-Django 1.11 – Query to exclude based on other table

1👍

Try this,

User.objects.exclude(invitation__team=1)

Where 1 is the PK/ID of the Team instance you want to specify

👤JPG

1👍

User.objects.filter(profile__team=None).exclude(invitation_set__team=your_team_to_exclude)

Leave a comment