2👍
✅
I think you could get all the Matching
objects with a filter applied on them, then get the Vote
objects using that results.
Something like:
representative_names = ["{name} ({group})".format(name=field[0], group=field[1]) for field in Matching.objects.filter(representative_remote_id=None).values_list('representative_name', 'representative_group')]
Vote.objects.exclude(representative_remote_id=None).filter(representative_name__in=representative_names)
Source:stackexchange.com