[Answer]-Unable to check if queryset is a subset

1👍

This is perfectly natural behaviour. Your query produces a JOIN on ValidatorMetaData and returns the PermissionValidatorMap for each pair of (PermissionValidatorMap, ValidatorMetaData) where ValidatorMetaData matches the query. Key here is that the validator_set__in lookup happens in the ValidatorMetaData table.

To get the desired behaviour, you’ll have to exclude each PermissionValidatorMap which has a related ValidatorMetaData not in validator_list, i.e.:

PermissionValidatorMap.objects.exclude(
    validator_set__in=ValidatorMetaData.objects.exclude(id__in=validator_list))
👤knbk

Leave a comment